I am trying to switch to a directory using cmd and then execute a batch file
e.g.
cmd /k cd "C:\myfolder" startbatch.bat
I have also tried (without success)
cmd cd /k cd "C:\myfolder" | startbatch.bat
Although the first line (cmd /k) seems to run ok, but the second command is never run. I am using Vista as the OS
Pressing SHIFT with the control key will move through the list backwards. If /C or /K is specified, then the remainder of the command line is processed as an immediate command in the new shell. Multiple commands separated by the command separator '&' or '&&' are accepted if surrounded by quotes.
A command line switch (also known as an option, a parameter, or a flag) acts as a modifier to the command you are issuing in the Command Prompt window, in a batch file, or in other scripts. Usually, a switch is a single letter preceded by a forward slash.
It might be that the cmd.exe file is listed in the Startup section in Task Manager – this means that every time your computer boots, cmd.exe will automatically load along with all other items listed in that section.
Correct syntax is:
cmd /k "cd /d c:\myfolder && startbatch.bat"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With