How do I start cmd.exe /k with multiple commands?

2019-07-09 04:35发布

Why doesn't the following code change the color and the title on cmd2? How, and what to do? The command changes color on cmd1, and sets the title on cmd2?

start cmd.exe /k TITLE TEST & color 02 & mode con: cols=160 lines=78 

1条回答
聊天终结者
2楼-- · 2019-07-09 05:14
start "TEST" cmd.exe /k "TITLE TEST & color 02 & mode con: cols=160 lines=78"

Without quoting the command that the new cmd instance must execute, the & is interpreted as a command concatenation after the start and so it is executed in the first instance. With quotes, it is part of the command to execute in the second cmd instance.

Also, as the start command sees the first quoted argument as the tile of the window to start, and we are going to use quotes, it is necessary to include a title in the command (or "" for no title).

查看更多
登录 后发表回答