Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cmd.exe /k switch

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

like image 543
Mike Avatar asked Jan 03 '12 14:01

Mike


People also ask

What does cmd.exe K do?

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.

What are cmd switches?

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.

Why does cmd.exe pop up on startup?

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.


1 Answers

Correct syntax is:

cmd /k "cd /d c:\myfolder && startbatch.bat" 
like image 98
Sedat Kapanoglu Avatar answered Sep 20 '22 06:09

Sedat Kapanoglu