Hi. I'm trying to write a batch script that checks to see if previously imported Registry settings succeeded. Here is the code I have so far: @echo offtitle %~nx0echo.SETLOCAL enabledelayedexpansionFOR %%I IN (HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced) DO (FOR %%J IN (HideIcons SharingWizardOn) DO (FOR /F "tokens=3 delims= " %%K IN ('reg query %%I /v %%J') DO (IF !ERRORLEVEL! EQU 0 (echo successful) ELSE (echo Error)))))PAUSEEXIT The second parameter in the second loop is there by design. I wanted the script to be able to handle missing keys. The ERRORLEVEL portion works fine when the key exists and is set to 0, allowing the IF statement to do it's thing. When it hits a non existent key, Reg Query spits out an error as you would expect but the ERRORLEVEL is not set. I know this because I placed an ECHO command between the second loop and the IF statement and it just gets ignored on the second iteration. The IF statement is not executed at all. I've tried various different things. I've used IF ERRORLEVEL 0, IF !ERRORLEVEL! EQU 1/0 ... etc. Every combination I could think of. I've checked the reg query command on it's own and it seems to set the Errorlevels correctly outside a loop. 0 for success and 1 for a fail. Can anyone tell me what I'm doing wrong? Or atleast point me in the right direction. I've been reading for two days now and am no closer to the answer. Thanks for reading. Here is a screenshot of the script being executed: