2017-04-02 59 views
0

我試圖執行這樣的命令(圓形支架上的CMD/C命令:如何執行與路徑名稱

CMD /C "C:\Users\Richard(R)D\abc.bat" 

我得到的錯誤信息:

'C:\Users\Richard' is not recognized as an internal or external command 

如何執行駐留在使用圓括號的文件夾中的命令?

回答

2

嘗試用旋轉曲線逸出括號^

CMD /C "C:\Users\Richard^(R^)D\abc.bat" 
+0

太棒了,這對我很有用 – RHAD

-1

你錯過了結束引號,因此命令會是這樣

CMD /C "C:\Users\Richard(R)D\abc.bat"

希望這將幫助ü解決它。

+0

對不起,這是一個錯字。我糾正了它。 – RHAD

+0

這並不能解決問題! – aschipfl

3

爲什麼?

如果你讀了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" 

或者一個通用的解決方案可以包括對文件

cmd /c ""C:\Users\Richard(R)D\abc.bat"" 

和更好的報價(如果從命令行執行)也避免第一個報價,以避免解析器在引用區域的問題開始/停止(在這種情況下不需要)

cmd /c ^""C:\Users\Richard(R)D\abc.bat""