【问题标题】:If command is successful, move on to the next如果命令成功,则继续下一步
【发布时间】:2014-10-20 16:16:08
【问题描述】:

我正在编写一个导入证书然后设置代理设置的批处理文件。我希望它继续设置代理只有在证书安装成功。

certutil.exe -addstore -f "CA" "C:\Users\%Username%\AppData\Local\Temp\IXP000.TMP\cert.cer"
certutil.exe -addstore -f "TrustedPublisher" "C:\Users\%Username%\AppData\Local\Temp\IXP000.TMP\cert.cer"
certutil.exe -addstore -f "root" "C:\Users\%Username%\AppData\Local\Temp\IXP000.TMP\cert.cer"

在继续执行接下来的两个命令之前,我在此处放置什么来检查最后三个命令是否成功?

reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 1 /f
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /t REG_SZ /d myproxyaddress

任何帮助将不胜感激!

【问题讨论】:

  • 可能重复:stackoverflow.com/q/734598/945456。您可能需要的最大信息是如何检查certutil 是否成功完成了工作。
  • 谢谢你,这就是我所追求的

标签: windows batch-file ssl proxy


【解决方案1】:

如果您不希望在处理第一个命令之前启动下一个命令行,您可以使用带有开关“/wait”的命令“Start”。这将执行命令并等待它完成。这看起来像:

start /wait certutil.exe -addstore -f "CA" "C:\Users\%Username%\AppData\Local\Temp\IXP000.TMP\cert.cer"
if %errorlevel% neq 0 exit /b %errorlevel% 
start /wait certutil.exe -addstore -f "TrustedPublisher" "C:\Users\%Username%\AppData\Local\Temp\IXP000.TMP\cert.cer"
if %errorlevel% neq 0 exit /b %errorlevel%
start /wait certutil.exe -addstore -f "root" "C:\Users\%Username%\AppData\Local\Temp\IXP000.TMP\cert.cer"
if %errorlevel% neq 0 exit /b %errorlevel%

【讨论】:

    猜你喜欢
    • 2023-04-04
    • 2017-10-28
    • 1970-01-01
    • 2012-02-26
    • 2018-11-02
    • 2022-12-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多