问题是在具有空格的文件夹中 报价必须在那里。
trone this:
C:\run.exe "C:\space folder\run.bat \"C:\space folder\input.txt\""
这是一个链接,您可以看到所有逃脱字符http://www.robvanderwoude.com/escapechars.php
我知道这是一个旧话题,但我找到了答案并想分享。
在窗户中,您不必逃脱报价。只是正常使用它们。在这种情况下:
C:\run.exe ""C:\space folder\run.bat" "C:\space folder\input.txt""
最终,我所需要的只是报价。
winrs -r:MACHINE001 ""C:\Program Files\MyApp\My App.exe" -x "LOTS OF PARAMETERS""
使用CMD(命令提示)运行程序涉及逃避“内部参数”。
examples
以下命令按预期工作(考虑内部引号):以内部引号的参数到批处理处理器的行为有所不同(信用为
tormod):
rafajaques
):> cmd /c echo ""C:\space folder\run.bat" && echo "C:\space folder\input.txt""
""C:\space folder\run.bat" && echo "C:\space folder\input.txt""
> cmd /c echo "C:\space folder\run.bat" && echo "C:\space folder\input.txt"
"C:\space folder\run.bat"
"C:\space folder\input.txt"
警告
警告是通过命令行参数分为三个步骤:要通过。 子过程
诠释和商店
,例如,在
cmd /c "echo something "" fishy "" here"
/c
echo something " fishy " here
当CMD解释这些参数并遇到这些参数时,它将其余的参数与“”相连,然后使用批处理处理器作为单个命令运行。这有效地显示:
/c
以下是连接的,没有任何错误:
something "" fishy "" here
注意
> cmd /c "echo something " /c fishy " here"
something " /c fishy " here
echo
或叉
|
。
另一方面,批处理处理器根据“”逃脱和空格字符分裂。这有效地将参数转换回了其原始版本。使用
&&
file.bat
Mastering引号
最后一个问题仍然存在:该示例呢?> file.bat /c "echo something "" fishy "" here"
/c
"echo something "" fishy "" here"
> file.bat ""C:\space folder\run.bat" "C:\space folder\input.txt""
""C:\space
folder\run.bat" "C:\space
一个参数areceived
AS:
> file.bat """C:\space folder\run.bat"" ""C:\space folder\input.txt"""
"""C:\space folder\run.bat"" ""C:\space folder\input.txt"""
lastly,批处理处理器或CMD实用程序后面的脚本引擎,可互换存储字符数据并命令。这是脚本语言的真正目的:混合数据和实用程序。考虑以下内容:
"C:\space folder\run.bat" "C:\space folder\input.txt"
我确定最后一个示例更适合C/C ++开发人员,在CMD和批处理处理器的时代,这足够了:)