Multiple Windows Command Line Commands

I open 3 cmd windows of different colors to help me distinguish between servers, etc. These commands are in the .bat file.

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

What I need to do is open them in a specific place, but I cannot force him to command the chains.

How can I cd connect to some folder structure right after cmd window starts?

+6
source share
3 answers

Use & :

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

Now you must quote the commands, otherwise & consumed by an external command line (for example, the one that runs the batch file), and not just the one that is running.


You also have another option - as far as I know, a recently launched command line will inherit the same current directory as the command line that launches it. Thus, you can 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 
+12
source
 start "" /d "c:\foldera" cmd /k color 4C start "" /d "c:\folderb" cmd /k color 5D start "" /d "c:\folderc" cmd /k color 2A 
+1
source

Try this code in a batch file. For the first cmd prompt, specify the directory structure instead of "cd \". the same applies to the prompts of the 2nd and 3rd cmd in the lines "d:" and "e:".

 start cmd /k color 4C REM following line for c:\ directory for 1st prompt cd\ start cmd /k color 5D REM for any other directory for 2nd prompt d: start cmd /k color 2A REM for another directory for 3rd prompt e: 
0
source

Source: https://habr.com/ru/post/944423/


All Articles