(As of 2014-02-04 17:00 Eastern Std Time) You have failed to show all the relevant code - particulary the code that generates RunLog.Log.
The code you show uses goto :32_2
and goto :64_2
, but you don't show those labels or their code. Most likely the code after label :32_2
is missing a goto :eof
(or exit /b
).
Regardless, the logic fault is in code that is not shown.
Updated answer in response to complete code now in question
It is as I suspected - You failed to put a GOTO :EOF
after the :32_3
section of code, so it simply falls into the :64_1
section.
You should use GOTO :EOF
instead of GOTO EOF
- then you do not need to put an explicit :EOF
label at the end of your script. Another alternative is to simply use EXIT /B
instead - it does exactly the same thing as GOTO :EOF
.
You can eliminate most of your labels since both the TRUE and FALSE of each IF statement GOTO the same label. You can simply let the code fall into the next section of code without any GOTO.
Also, the ELSE of your first IF is not really needed. It too can simply fall into the :32 section when it is not :64
@echo off
for /F "tokens=1 delims=" %%i in (C:\Outlook\OVLK.txt) do call :proccheck %%i
exit /b
:proccheck
REG QUERY \\%1\%proctype% 2>nul >nul
if %errorlevel% == 0 goto :64
:32 (Note - this label isn't needed, but I preserved it for documentation purposes)
echo %1 is 32bit >> "C:\Outlook\RegeditList.txt"
REG QUERY \\%1\%regkey1_64% > nul
if %errorlevel%== 0 (
echo %regkey1_64% Found! >> "C:\Outlook\RegeditList.txt"
REG DELETE \\%1\%regkey1_64% /f >> "C:\Outlook\RegeditList.txt"
) else (
echo %regkey1_64% not found on: %1 - Check >> "C:\Outlook\KeysNotFoundlist.txt"
)
REG QUERY \\%1\%regkey2_32% > nul
if %errorlevel%== 0 (
echo %regkey2_32% Found! >> "C:\Outlook\RegeditList.txt"
REG DELETE \\%1\%regkey2_32% /f >> "C:\Outlook\RegeditList.txt"
) else (
echo %regkey2_32% not found on: %1 - Check >> "C:\Outlook\KeysNotFoundlist.txt"
)
REG QUERY \\%1\%regkey3_32% > nul
if %errorlevel%== 0 (
echo %regkey3_32% Found! >> "C:\Outlook\RegeditList.txt"
REG DELETE \\%1\%regkey3_32% /f >> "C:\Outlook\RegeditList.txt"
echo. >> "C:\Outlook\RegeditList.txt"
) else (
echo %regkey3_32% not found on: %1 - Check >> "C:\Outlook\KeysNotFoundlist.txt"
echo. >> "C:\Outlook\KeysNotFoundlist.txt"
echo. >> "C:\Outlook\RegeditList.txt"
)
echo Checked %1 now going to loop! >> "C:\Outlook\RunLog.log"
echo. >> "C:\Outlook\RunLog.log"
exit /b
:64
echo %1 is 64bit >> "C:\Outlook\RegeditList.txt"
REG QUERY \\%1\%regkey1_64% > nul
if %errorlevel%== 0 (
echo %regkey1_64% Found! >> "C:\Outlook\RegeditList.txt"
REG DELETE \\%1\%regkey1_64% /f >> "C:\Outlook\RegeditList.txt"
) else (
echo %regkey1_64% not found on: %1 - Check >> "C:\Outlook\KeysNotFoundlist.txt"
)
REG QUERY \\%1\%regkey2_64% > nul
if %errorlevel%== 0 (
echo %regkey2_64% Found! >> "C:\Outlook\RegeditList.txt"
REG DELETE \\%1\%regkey2_64% /f >> "C:\Outlook\RegeditList.txt"
) else (
echo %regkey2_64% not found on: %1 - Check >> "C:\Outlook\KeysNotFoundlist.txt"
)
REG QUERY \\%1\%regkey3_64% > nul
if %errorlevel%== 0 (
echo %regkey3_64% Found! >> "C:\Outlook\RegeditList.txt"
REG DELETE \\%1\%regkey3_64% /f >> "C:\Outlook\RegeditList.txt"
echo. >> "C:\Outlook\RegeditList.txt"
) else (
echo %regkey3_64% not found on: %1 - Check >> "C:\Outlook\KeysNotFoundlist.txt"
echo. >> "C:\Outlook\KeysNotFoundlist.txt"
echo. >> "C:\Outlook\RegeditList.txt"
)
echo Checked %1 now going to loop! >> "C:\Outlook\RunLog.log"
echo. >> "C:\Outlook\RunLog.log"
exit /b
Another option is to use the &&
operator to conditionally execute code if the prior command was successful, and ||
to conditionally excecute code if the prior command failed. You do not need any CALL or GOTO at all.
@echo off
for /F "tokens=1 delims=" %%i in (C:\Outlook\OVLK.txt) do (
REG QUERY \\%%i\%proctype% 2>nul >nul && (
REM 64 section
echo %%i is 64bit >> "C:\Outlook\RegeditList.txt"
REG QUERY \\%%i\%regkey1_64% > nul && (
REG DELETE \\%%i\%regkey1_64% /f >> "C:\Outlook\RegeditList.txt"
echo %regkey1_64% Found! >> "C:\Outlook\RegeditList.txt"
) || (
echo %regkey1_64% not found on: %%i - Check >> "C:\Outlook\KeysNotFoundlist.txt"
)
REG QUERY \\%%i\%regkey2_64% > nul && (
REG DELETE \\%%i\%regkey2_64% /f >> "C:\Outlook\RegeditList.txt"
echo %regkey2_64% Found! >> "C:\Outlook\RegeditList.txt"
) || (
echo %regkey2_64% not found on: %%i - Check >> "C:\Outlook\KeysNotFoundlist.txt"
)
REG QUERY \\%%i\%regkey3_64% > nul && (
echo %regkey3_64% Found! >> "C:\Outlook\RegeditList.txt"
REG DELETE \\%%i\%regkey3_64% /f >> "C:\Outlook\RegeditList.txt"
echo. >> "C:\Outlook\RegeditList.txt"
) || (
echo %regkey3_64% not found on: %%i - Check >> "C:\Outlook\KeysNotFoundlist.txt"
echo. >> "C:\Outlook\KeysNotFoundlist.txt"
echo. >> "C:\Outlook\RegeditList.txt"
)
echo Checked %%i now going to loop! >> "C:\Outlook\RunLog.log"
echo. >> "C:\Outlook\RunLog.log"
) || (
REM 32 section
echo %%i is 32bit >> "C:\Outlook\RegeditList.txt"
REG QUERY \\%%i\%regkey1_64% > nul && (
REG DELETE \\%%i\%regkey1_64% /f >> "C:\Outlook\RegeditList.txt"
echo %regkey1_64% Found! >> "C:\Outlook\RegeditList.txt"
) || (
echo %regkey1_64% not found on: %%i - Check >> "C:\Outlook\KeysNotFoundlist.txt"
)
REG QUERY \\%%i\%regkey2_32% > nul && (
REG DELETE \\%%i\%regkey2_32% /f >> "C:\Outlook\RegeditList.txt"
echo %regkey2_32% Found! >> "C:\Outlook\RegeditList.txt"
) || (
echo %regkey2_32% not found on: %%i - Check >> "C:\Outlook\KeysNotFoundlist.txt"
)
REG QUERY \\%%i\%regkey3_32% > nul && (
echo %regkey3_32% Found! >> "C:\Outlook\RegeditList.txt"
REG DELETE \\%%i\%regkey3_32% /f >> "C:\Outlook\RegeditList.txt"
echo. >> "C:\Outlook\RegeditList.txt"
) || (
echo %regkey3_32% not found on: %%i - Check >> "C:\Outlook\KeysNotFoundlist.txt"
echo. >> "C:\Outlook\KeysNotFoundlist.txt"
echo. >> "C:\Outlook\RegeditList.txt"
)
echo Checked %%i now going to loop! >> "C:\Outlook\RunLog.log"
echo. >> "C:\Outlook\RunLog.log"
)
)