如何在使用start命令时通过批处理脚本更改命令窗口的颜色 [英] How can i change the colour of a command window via batch script when using the start command

查看:327
本文介绍了如何在使用start命令时通过批处理脚本更改命令窗口的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用robocopy



我已经粘贴了一个样本,从而运行一些小批量脚本,以便将数据从一个位置复制到另一个位置。



我需要做的每一个这些批处理文件是打开和运行robocopy命令列出(它正在做),但我需要robocopy输出窗口设置颜色每批处理文件



批处理文件读取如下
start robocopy.exesourcedestination/ MIR /Log:e:\outputlog.txt / TEE



启动robocopy.exesourcedestination/ MIR /Log:e:\outputlog.txt / TEE



start robocopy.exesourcedestination/ MIR /Log:e:\outputlog.txt / TEE



一次,这是罚款,但我不能使robocopy窗口改变颜色。 (上面的3是很好的,因为一种颜色,我们将运行另一个批处理文件,但使用不同的颜色来区分副本)



这是可能的。 >

我知道cmd命令可以有一个颜色更改,但只适用于该窗口。因为robocopy命令打开一个新窗口的颜色设置不会传递下来,



任何帮助或想法,这将非常感谢。我们需要保持代码的简单,因为各种用户需要使用它

解决方案

cmd 可以通过/ T参数指定颜色。例如: start cmd / T:5A 启动一个带有紫色(5)背景和浅绿色文本(A)的新命令窗口



您可以使用/ C或/ K在新实例中启动一个新命令(C完成后终止)



ie start cmd / T:5A / K robocopy ... 应该这样做


i am running a number of small batch scripts to copy data from one location to another using robocopy

i have pasted a sample below.

what i need to do for each of these batch files is get it to open and run the robocopy commands listed (which it is doing) but i need the robocopy output windows to be in set colours per batch file.

the batch file reads as below start robocopy.exe "source" "destination" /MIR /Log:e:\outputlog.txt /TEE

start robocopy.exe "source" "destination" /MIR /Log:e:\outputlog.txt /TEE

start robocopy.exe "source" "destination" /MIR /Log:e:\outputlog.txt /TEE

the above would all run at once which is fine but i cannot make the robocopy windows change colour. (the 3 above are fine as one colour we would run another batch file as above but with a different colour to differentiate between copies)

is this even possible.

i know the cmd command can have a colour change which works but only for that window. as the robocopy command opens up a new window the colour settings do not pass down,

any help or ideas on this would be greatly appreciated. we need to keep the code simple as various users need to use it

解决方案

cmd can take a /T parameter to specify the colours. Eg: start cmd /T:5A starts a new command windows with purple(5) background and light green text(A)

You can use /C or /K to start a new command within the new instance ( C terminates on completion)

i.e. start cmd /T:5A /K robocopy... should do it

这篇关于如何在使用start命令时通过批处理脚本更改命令窗口的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆