Reputation: 5444
I'm trying to write a simple batch file to initialize some tools I need on windows startup. This is what I've at the moment:
@echo off
start /d "C:\Program Files\Sublime Text 3" sublime_text.exe
start cmd.exe /k cd /d "D:xampp/htdocs/webshop"
What I'd like to do is to execute the command compass watch
once the directory has changed.
I tried start cmd.exe /k cd /d "D:xampp/htdocs/webshop" /k "compass watch"
but it refers to the cd command then and thus throws me an error message (The system cannot find the path specified).
Any suggestions?
EDIT
To clarify what I need:
cd
to the relevant directorycompass watch
(in that directory)I normally do this by manually typing in the commands into the console as listed above. What I'd like to have is a simple .bat file that does exactly that with just one click.
Upvotes: 4
Views: 13230
Reputation: 612964
You state in the comments that you don't need a separate interpreter. In which case I believe you can do it like this:
@echo off
start /d "C:\Program Files\Sublime Text 3" sublime_text.exe
start /d D:\xampp\htdocs\webshop compass watch
Upvotes: 5
Reputation: 41234
This should work to launch the exe, and change folder, then use cmd /k to execute the compass command and leave the console open.
@echo off
start "" /d "C:\Program Files\Sublime Text 3" sublime_text.exe
cd /d "D:xampp/htdocs/webshop"
cmd.exe /k "compass watch"
Upvotes: 0
Reputation: 9545
You have to use Backslash in your path "\". Did you try :
@echo off
"C:\Program Files\Sublime Text 3\sublime_text.exe"
cd /d "D:\xampp\htdocs\webshop"
"D:\xampp\htdocs\webshop\compass watch.exe"
Upvotes: 0
Reputation: 18827
This an example to open Firefox.exe.So you should do like this, for your programs
@echo off
echo Try to open Firefox ....
CD /D %programfiles%\Mozilla Firefox\ & Start Firefox.exe
Pause
Try This :
@echo off
CD /D %programfiles%\Sublime Text 3 & Start sublime_text.exe
CD /D D:\xampp/htdocs/webshop & Start compass watch
Pause
Upvotes: 0