Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

windows command line multiple commands

Tags:

windows

cmd

I am opening 3 cmd windows in different colours to help me distinguish between servers etc. These commands are in a .bat file.

start cmd /k color 4C
start cmd /k color 5D 
start cmd /k color 2A 

What I need to do is have them open up at a specific location but I can't seem to get it to chain commands.

How can I cd in to some folder structure immediately after starting a cmd window?

like image 832
Neil Avatar asked May 07 '13 08:05

Neil


1 Answers

Use &:

start cmd /k "color 4C & cd \"

You have to quote the commands now, otherwise the & is consumed by the outer command prompt (e.g. the one running the batch file) rather than the newly launched one.


You also have another option - so far as I'm aware, a newly launched command prompt inherits the same current directory as the command prompt that launches it. So you could change your batch file to:

cd \location1
start cmd /k color 4C
cd \location2
start cmd /k color 5D 
cd \location3
start cmd /k color 2A 
like image 183
Damien_The_Unbeliever Avatar answered Nov 15 '22 08:11

Damien_The_Unbeliever