1

I'm writing a batch file that imports a certificate then sets proxy settings. I would like it to proceed in setting the proxy only if the certificates are successfully installed.

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"

What do I put here to check if the last three commands were successful before proceeding with the next two?

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

Any help would be greatly appreciated!

Jeff B
  • 7,565
  • 15
  • 53
  • 128
babylon88
  • 11
  • 1
  • Possible duplicate: http://stackoverflow.com/q/734598/945456. The biggest piece of information you probably need is how to check if `certutil` successfully completed its work. – Jeff B Oct 20 '14 at 16:50
  • thank you that is what i was after – babylon88 Oct 21 '14 at 01:41

1 Answers1

0

If you don't want the next commandline to start before the first command is handled you can use the command "Start" with the switch "/wait". This will execute the command and wait for it to complete. This would look like:

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%
Armand0
  • 43
  • 1
  • 7