0
votes

I am trying to search the Registry for key values using the following Batch file, but there are inconsistencies with errorlevel returned:

@Echo off
setlocal
set PATHFIX=%CD%
set LOGFILE=%SYSTEMDRIVE%\windows\IA\%COMPUTERNAME%-ISPA_Windows_7_STIG_V1R9_27_Jul_2012-%DATE%.txt
echo Log file name will be %LOGFILE%
echo Security Template logfile for %COMPUTERNAME% > %LOGFILE%
echo -- >> %LOGFILE%
for /f "delims=*" %%i in ('time /t') do set TIME=%%i
echo Date run: %DATE% >> %LOGFILE%
echo Time run: %TIME% >> %LOGFILE%
echo -- >> %LOGFILE%
echo Windows_7_STIG_V1R9 27 Jul 2012 >> %LOGFILE%
echo =============================================================================================== >> %LOGFILE%
FOR /F "tokens=1,2,3,4,5,6,7,8,9 delims=    " %%F IN (WINDOWS_7_V1R9.txt) DO (
    reg query "%%F" /v "%%H" /t "%%I" | Find "%%J"

    IF not ERRORLEVEL 1 (
        echo %%G    Compliant   
        echo %%G    %%K Compliant   %%M>> %LOGFILE%
        echo -- >> %LOGFILE%
    ) ELSE (
        echo %%G    Non-Compliant   
        echo %%G    %%K Non-Compliant   %%F\%%H %%I %%J >> %LOGFILE%
        echo -- >> %LOGFILE%
    )
)
echo -- >> %LOGFILE%
:PATCHES_COMPLETE
for /f "delims=*" %%i in ('time /t') do set TIME=%%i
echo -- >> %LOGFILE%
echo ISPA-STIG for %COMPUTERNAME% completed at: %TIME% >> %LOGFILE%

pause

exit

The text file is set up as follows:

HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\System V-1075 ShutdownWithoutLogon REG_DWORD 0x1 ECSC-1 SV-25111r1_rule Display Shutdown Button

Any assistance would be greatly appreciated.

1

1 Answers

0
votes

1) it is not possible to search registry with batch

2) you should never do automated searches with registry as this can inturupt other things and it may also delete un specified keys

3)the only way to navigate the registry automatically is with a .reg file

sorry if this seemed mean at all i just like to use numbers.

hope that this helps you!