2012-08-10 167 views
0

我試圖尋找使用下面的批處理文件鍵值註冊表,但也有不一致之處與ERRORLEVEL返回:批處理文件搜索註冊表

@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 

的文本文件設置如下:

HKLM \ Software \ Microsoft \ Windows \ CurrentVersion \ Policies \ System V-1075 ShutdownWithoutLogon REG_DWORD 0x1 ECSC-1 SV-25111r1_rule顯示關機按鈕

任何援助將不勝感激。

回答

0

1)這是不可能搜索註冊表有一批

2)你永遠不應該這樣做自動搜索與註冊表,因爲這可能inturupt其他東西 ,它也可能會刪除未指定的鍵

3)自動導航註冊表的唯一方法是使用.reg文件

對不起,如果這似乎意味着我只是喜歡使用數字。

希望這可以幫助你!