如何在路径名中使用(圆括号)执行CMD/C命令
我正在尝试执行如下命令:如何在路径名中使用(圆括号)执行CMD/C命令,cmd,Cmd,我正在尝试执行如下命令: CMD /C "C:\Users\Richard(R)D\abc.bat" 我收到错误消息: 'C:\Users\Richard' is not recognized as an internal or external command 如何执行位于使用圆括号的文件夹中的命令?尝试用扬抑符转义括号^ CMD /C "C:\Users\Richard^(R^)D\abc.bat" 尝试用扬抑符转义括号^ CMD /C "C:\Users\Richard^(R^)D\
CMD /C "C:\Users\Richard(R)D\abc.bat"
我收到错误消息:
'C:\Users\Richard' is not recognized as an internal or external command
如何执行位于使用圆括号的文件夹中的命令?尝试用扬抑符转义括号^
CMD /C "C:\Users\Richard^(R^)D\abc.bat"
尝试用扬抑符转义括号^
CMD /C "C:\Users\Richard^(R^)D\abc.bat"
您遗漏了结尾的引号,因此命令将如下所示
CMD/C“C:\Users\Richard(R)D\abc.bat”
希望这能帮助你解决问题。你漏掉了结尾的引号,因此命令如下所示
CMD/C“C:\Users\Richard(R)D\abc.bat”
希望这能帮你解决问题。为什么
如果阅读cmd/?
输出,您将发现
If /C or /K is specified, then the remainder of the command line after
the switch is processed as a command line, where the following logic is
used to process quote (") characters:
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 whitespace characters between the
two quote characters
- the string between the two quote characters is the name
of an executable file.
2. Otherwise, old behavior is to see if the first character is
a quote character and if so, strip the leading character and
remove the last quote character on the command line, preserving
any text after the last quote character.
获取删除的引号和剩余的命令
cmd /c C:\Users\Richard(R)D\abc.bat
括号有问题
怎么做
对于这个精确的命令,可以对括号进行转义
cmd /c "C:\Users\Richard^(R^)D\abc.bat"
或者,对于一般解决方案,您可以为文件添加引号
cmd /c ""C:\Users\Richard(R)D\abc.bat""
更好的是(如果从命令行执行),也可以转义第一个引号,以避免在引号区域start/stop中出现解析器问题(在这种情况下不需要)
为什么?
如果阅读cmd/?
输出,您将发现
If /C or /K is specified, then the remainder of the command line after
the switch is processed as a command line, where the following logic is
used to process quote (") characters:
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 whitespace characters between the
two quote characters
- the string between the two quote characters is the name
of an executable file.
2. Otherwise, old behavior is to see if the first character is
a quote character and if so, strip the leading character and
remove the last quote character on the command line, preserving
any text after the last quote character.
获取删除的引号和剩余的命令
cmd /c C:\Users\Richard(R)D\abc.bat
括号有问题
怎么做
对于这个精确的命令,可以对括号进行转义
cmd /c "C:\Users\Richard^(R^)D\abc.bat"
或者,对于一般解决方案,您可以为文件添加引号
cmd /c ""C:\Users\Richard(R)D\abc.bat""
更好的是(如果从命令行执行),也可以转义第一个引号,以避免在引号区域start/stop中出现解析器问题(在这种情况下不需要)