【问题标题】:Problems running command with parameters with path with spaces使用带空格的路径参数运行命令时出现问题
【发布时间】:2015-07-16 13:10:27
【问题描述】:

我需要运行命令:

certmgr.exe -add MyCert.cer -s -r localMachine trustedpublisher

现在我遇到的问题是 certmgr.exe 不在我的路径中。我也不想将它添加到我的路径中。

好的,我当然可以这样做:

set PATH=%PATH%;C:\Program Files (x86)\Microsoft Visual Studio 11.0

certmgr.exe 的路径是上面的 Microsoft Visual Studio 11.0 路径。

但我应该能够使用可执行文件的完整路径运行命令。

所以我尝试了以下方法:

>"C:\Program Files (x86)\Microsoft Visual Studio 11.0\certmgr.exe" -add comodo.cer -s -r localMachine trustedpublisher
'"C:\Program Files (x86)\Microsoft Visual Studio 11.0\certmgr.exe"' is not recognized as an internal or external command, operable program or batch file.

>"..\..\..\Program Files (x86)\Microsoft Visual Studio 11.0\certmgr.exe" -add comodo.cer -s -r localMachine trustedpublisher
'"..\..\..\Program Files (x86)\Microsoft Visual Studio 11.0\certmgr.exe"' is not recognized as an internal or external command, operable program or batch file.

>start "C:\Program Files (x86)\Microsoft Visual Studio 11.0\certmgr.exe" -add comodo.cer -s -r localMachine trustedpublisher
The system cannot find the file -add.

>set THISPROG=C:\Program Files (x86)\Microsoft Visual Studio 11.0\certmgr.exe

>%THISPROG% -add comodo.cer -s -r localMachine trustedpublisher
'C:\Program' is not recognized as an internal or external command, operable program or batch file.

>"%THISPROG%" -add comodo.cer -s -r localMachine trustedpublisher
'"C:\Program Files (x86)\Microsoft Visual Studio 11.0\certmgr.exe"' is not recognized as an internal or external command, operable program or batch file.

如何运行命令:

"C:\Program Files (x86)\Microsoft Visual Studio 11.0\certmgr.exe" -add comodo.cer -s -r localMachine trustedpublisher

没有将“C:\Program Files (x86)\Microsoft Visual Studio 11.0 添加到我的路径?

【问题讨论】:

  • 你设法让它工作了吗?这绝对是在使用记事本示例!! :0)
  • where /R C:\ certmgr.exe 的输出是什么?或者(相同)dir /B /S C:\certmgr.exe?

标签: windows cmd


【解决方案1】:

试试这个...

set THISPROG="C:\Program Files (x86)\Microsoft Visual Studio 11.0\certmgr.exe"

(注意路径周围的"")然后

%THISPROG% -add comodo.cer -s -r localMachine trustedpublisher

我似乎在我的 Visual Studio 文件夹中找不到您提到的文件,但我只是测试了这种格式以在记事本中打开文件。


在我的测试中,我在C:\a.txt 有一个文件,我使用了...

set AAA="C:\Windows\System32\notepad.exe"
%AAA% C:\a.txt

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-06-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多