Reputation: 30146
I have the following directory structure:
I've created the StartAll.bat
script in order to open a CMD window in each folder:
start cmd.exe /k cd Folder1 & set prompt=Folder1:
start cmd.exe /k cd Folder2 & set prompt=Folder2:
start cmd.exe /k cd Folder3 & set prompt=Folder3:
start cmd.exe /k cd Folder4 & set prompt=Folder4:
However, I'm experiencing a very weird behavior when running it:
Folder1
Folder1:
Folder2:
Folder3:
As you can see, a proper window for the last folder is missing.
I'm observing the exact same behavior regardless of the number of folders.
Any idea what is going on here?
I would also appreciate alternative suggestions for achieving this purpose.
For all it matters, I am running this on Windows 10.
Thank you for your help.
Upvotes: 2
Views: 69
Reputation: 3471
You should use this:
start cmd.exe /k cd Folder1 ^& set prompt=Folder1:
start cmd.exe /k cd Folder2 ^& set prompt=Folder2:
start cmd.exe /k cd Folder3 ^& set prompt=Folder3:
start cmd.exe /k cd Folder4 ^& set prompt=Folder4:
Right now the &
character is not escaped which causes it to view the second part of your command as a new command within the scope of startAll.bat
This causes your commands to be executed like this:
which then causes your 4 new windows to have prompts like this:
startAll.bat
cd
ed into folder2etc...
Upvotes: 2