如何使用 Windows START with cmd.exe?

How to use Windows START with cmd.exe?

我想设置命令行语句的优先级,例如copy test.txt test2.txt

我找到了 Windows START command, which allows to set priority of an executable. more info

所以我假设我需要将 cmd.exe 传递给 START。

但这不起作用:

START /LOW "mycopy" "cmd.exe copy test.txt test4.txt"

它returns:The system cannot find the file cmd.exe copy test.txt test4.txt.

下面打开一个新的空命令window,复制没有发生:

START /LOW "mycopy" "cmd ""copy test.txt test4.txt"""

以下returnsMicrosoft Windows [Version 6.1.7601] Copyright (c) 2009 Microsoft Corporation. All rights reserved.,并且复制不发生

START /LOW "mycopy" /B cmd.exe "copy test.txt test4.txt"

单引号、双引号或双引号的其他变体。

如何实现? (越简单越好:)

如果新命令window在执行后自行关闭,则更可取。

ps,我也对涉及 PowerShell 的方法持开放态度。

谢谢!

您不需要所有这些引用,或者 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 files\foo\bar.exe /hi /mom
      ^^^^^^^^^^---program  (no such file/command)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^ arguments to this bad command

v.s.

start "c:\program files\foo\bar.exe" /hi /mom
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--command
                                     ^^^^^^^^---arguments