0

我正在尝试使用以下批处理文件在注册表中搜索键值,但返回的错误级别不一致:

@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 显示关机按钮

任何帮助将不胜感激。

4

2 回答 2

0

1) 无法批量搜索注册表

2)您永远不应该使用注册表进行自动搜索,因为这可能会破坏其他内容,并且还可能删除未指定的键

3) 自动导航注册表的唯一方法是使用 .reg 文件

抱歉,如果这看起来很卑鄙,我只是喜欢使用数字。

希望这对你有帮助!

于 2013-02-10T05:41:23.153 回答
0

您无法使用批处理搜索注册表,因此无法回答您的问题。抱歉 :) windows 只是不允许它 f

于 2021-11-20T16:43:55.753 回答