我想设置命令行语句的优先级,例如copy test.txt test2.txt
我找到了Windows START
命令,它允许设置可执行文件的优先级。更多信息
所以我假设我需要将cmd.exe
传递给START。
但这不起作用:
START /LOW "mycopy" "cmd.exe copy test.txt test4.txt"
返回:The system cannot find the file cmd.exe copy test.txt test4.txt.
以下操作将打开一个新的空命令窗口,并且不会发生复制:
START /LOW "mycopy" "cmd ""copy test.txt test4.txt"""
以下返回Microsoft Windows [Version 6.1.7601] Copyright (c) 2009 Microsoft Corporation. All rights reserved.
,并且不会发生复制。
START /LOW "mycopy" /B cmd.exe "copy test.txt test4.txt"
也不是单引号、双引号或双引号的其他变体。
如何做到这一点?(越简单越好:(
如果新命令窗口在执行后自动关闭,则首选。
ps,我也对涉及PowerShell的方法持开放态度。
thx!
您不需要所有这些引用,或者start
认为这是唯一的参数:命令本身。
这项工作:
START /LOW "mycopy" cmd.exe /c copy test.txt test4.txt
请注意/c
参数,该参数告诉cmd
执行以下命令。
start
语法基本上是:
start cmd_to_run argument to cmd
由于您引用了整个命令,因此您实际上是在尝试运行一个文件名为cmd.exe copy ....
的程序,而该程序显然不存在。
只需删除这些报价:
start /low "mycopy" cmd copy test.txt test4.txt
^-command to run
^^^^^^^^^^^^^^^^^^^^^^-- arguments to command
如果你在文件名中包含一个包含空格的路径,或者程序名本身包含空格,例如,那么你唯一需要引用命令本身的时间
start c:program filesfoobar.exe /hi /mom
^^^^^^^^^^---program (no such file/command)
^^^^^^^^^^^^^^^^^^^^^^^^^^ arguments to this bad command
v.s.
start "c:program filesfoobar.exe" /hi /mom
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--command
^^^^^^^^---arguments