How to change the color of a new CMD window (along with a custom prompt) created with a run script

I already know how to create a new cmd window from a script batch with a custom color and a new cmd window with a custom prompt. However, I want to find a way to combine them together ...

Here's what I have in my batch file to create a new cmd window with a custom prompt (in this case, the custom prompt is the Windows version information):

start cmd /k "prompt $v"

      

... And this is what I am doing to create a new cmd window with custom color:

start cmd /k "color 42"

      

I tried the following to combine the two, but none of them work:

start cmd /k "color 42" /k "prompt $v"

start cmd /k"color 42" "prompt $v"

      

If anyone can help me point in the right direction that would be great. Browsing through Google and other forums, but after spending over an hour fruitlessly searching, I thought I was asking a question here ...

+3


source to share


2 answers


The only thing you are missing is the operator who is to concatenate several commands in a single line: &

.

start cmd /k "color 42&prompt $v"

      



This statement works in all situations, not just the command line for the CMD command. There are several concatenation operators with different behavior:

  • &

    - Executes the following command
  • &&

    - Executes only the next command if the previous command was successful (ERRORLEVEL = 0)
  • ||

    - Executes only the next command if the previous command is not executed (ERRORLEVEL <> 0)
+6


source


try:



start cmd /k"color 42; prompt $v"

      

-1


source







All Articles