'Trying to open a new cmd window then run multiple commands in it
I am facing a rather annoying issue when trying to write a batchscript file for my assignment, the assignment asks me to open a new command prompt window, change its color and make it print the current windows version. I can make it open the new window and change the color but no matter what I do it will always execute any new commands including the ver command on the old command prompt window, I have tried using & to run multiple commands but it just does nothing.
start cmd /k color F1 & ver
pause
This is the code I have now, any help would be appreciated
Solution 1:[1]
To undertake the task you've specifically shown us, there is no need whatsoever to use the color command, and as a result, include an ampersand to join two commands.
If you open a Command Prompt window, type cmd.exe /? and press the ENTER key, you should see that there is a /T option you can use.
Start %SystemRoot%\System32\cmd.exe /T:F1 /D /K Ver
Solution 2:[2]
Have you tried
start "My assignment" cmd /k "color F1 & ver"
Note that the window title is the first quoted string in the start command.
Solution 3:[3]
Without double quotes only the "color f1" command is being passed to your new cmd window.
start cmd /k "color F1 & ver"
pause
I think will give you the results you want.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Compo |
| Solution 2 | Magoo |
| Solution 3 | kiyell |
