我正在创建一个GPO来检查32位和64位计算机上是否存在注册表值。我宁愿只创建一个脚本,而不是两个。脚本应检查键的值,如果是某个文本,则退出,如果不是,则删除该值。
我认为reg查询可以工作,但是不会查询密钥。
KEY:HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\DirectX
或者密钥:>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\DirectX
VALUE: 00 00 00 09 1A
如果该值存在,请保留,否则删除它。
echo off
reg query HKLM\SOFTWARE\Wow6432Node\Microsoft\CCM\Security<br>
if %errorlevel% == 1 goto not_64bit
reg query "HKLM\SOFTWARE\Wow6432Node\Microsoft\CCM\Security" /v AllowedRootCAHashCode /t REG_SZ /d "00 00 00 09 1A"
if %errorlevel% == 0 goto end
Reg Delete HKLM\SOFTWARE\Wow6432Node\Microsoft\CCM\Security /v AllowedRootCAHashCode /t
goto end
:not_64bit
reg query "HKLM\SOFTWARE\Microsoft\CCM\Security" /v AllowedRootCAHashCode /t REG_SZ /d "00 00 00 09 1A"
if %errorlevel% == 0 goto end
Reg Delete HKLM\SOFTWARE\Microsoft\CCM\Security /v AllowedRootCAHashCode /f
:end
答案 0 :(得分:0)
这可能有所帮助 - 它没有经过测试。
@echo off
reg query "HKLM\SOFTWARE\Wow6432Node\Microsoft\CCM\Security" >nul 2>&1 || goto not_64bit
reg query "HKLM\SOFTWARE\Wow6432Node\Microsoft\CCM\Security" /v AllowedRootCAHashCode /t REG_SZ |find "00 00 00 09 1A" >nul
if errorlevel 1 Reg Delete "HKLM\SOFTWARE\Wow6432Node\Microsoft\CCM\Security" /v AllowedRootCAHashCode /f
goto :EOF
:not_64bit
reg query "HKLM\SOFTWARE\Microsoft\CCM\Security" /v AllowedRootCAHashCode /t REG_SZ |find "00 00 00 09 1A" >nul 2>&1 && goto :EOF
Reg Delete "HKLM\SOFTWARE\Microsoft\CCM\Security" /v AllowedRootCAHashCode /f
答案 1 :(得分:0)
这就是诀窍......
@echo off
reg query "HKLM\SOFTWARE\Wow6432Node\Microsoft\CCM\Security" || goto not_64bit
reg query "HKLM\SOFTWARE\Wow6432Node\Microsoft\CCM\Security" /v AllowedRootCAHashCode /t REG_SZ |findstr -i /c:"065fac" || goto 64bitkey
goto :end
:64bitkey
Reg Add "HKLM\SOFTWARE\Wow6432Node\Microsoft\CCM\Security" /v AllowedRootCAHashCode /t REG_SZ /d " " /f
goto :end
:not_64bit
reg query "HKLM\SOFTWARE\Microsoft\CCM\Security" /v AllowedRootCAHashCode /t REG_SZ |findstr -i /c:"065fac" || goto 32bitkey
goto :end
:32bitkey
Reg Add "HKLM\SOFTWARE\Microsoft\CCM\Security" /v AllowedRootCAHashCode /t REG_SZ /d " " /f
:end