Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open cmd, change directory and execute command

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:

  1. Open console
  2. cd to the relevant directory
  3. Execute the command compass 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.

like image 926
damian Avatar asked Oct 20 '25 03:10

damian


1 Answers

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
like image 129
David Heffernan Avatar answered Oct 22 '25 04:10

David Heffernan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!