我正在尝试这样做:
cmd.exe /C "C:\Program Files\Somewhere\SomeProgram.exe" > "C:\temp\Folder Containing Spaces\SomeProgram.out"
Run Code Online (Sandbox Code Playgroud)
但是,我遇到的问题与cmd.exe的工作方式有关.如果您阅读了它的帮助,它会以一种特殊的方式处理"字符.请查看问题末尾的帮助.所以,这不能正确执行...我猜测cmd.exe剥离了一些引号,这使得声明不正确.
我能成功地做到这一点:
// quotes not required around folder with no spaces
cmd.exe /C "C:\Program Files\Somewhere\SomeProgram.exe" > C:\temp\FolderWithNoSpaces\SomeProgram.out
Run Code Online (Sandbox Code Playgroud)
但是,我真的需要第一个工作.是否存在cmd.exe使用的奇怪报价处理?我希望它保留所有引号,但似乎没有选项让它这样做.
输出的帮助:cmd /?
如果指定了/ C或/ K,则将切换后的命令行的其余部分作为命令行处理,其中以下逻辑用于处理quote(")字符:
1. If all of the following conditions are met, then quote characters
on the command line are preserved:
- no /S switch
- exactly two quote characters
- no special characters between the two quote characters,
where special is one of: &<>()@^|
- there are one or more …Run Code Online (Sandbox Code Playgroud)