我有一个要删除的注册表项/值/条目的列表(基本上是下面#3 中的列表,没有 REG DELETE 内容)。它按原样工作,但我想要一批......
I. 如果%~dp0中不存在list.txt,则写入listfile.txt本身
示例:
set "ListFile=%TEMP%\ListFile.txt"
set "List=%~dp0list.txt"
if not exist "%List%" (
(
echo Some regisrtry key
echo Some registry value
echo Some registry subkey
echo No idea how it should all be written like
) >"%ListFile%"
)
二. 使用 REG QUERY 检查列表中每个项是否存在,并有一个 ERRORLEVEL
如果存在..
- REG 将其导出到其自己的有效 .reg(如果出现问题可以导入回来)。
示例:
for /f %%A in (%src%) do (
if not exist "%bkp%\%%A" md "%bkp%\%%A"
reg export "%%A" "%bkp%\%%A\key.reg"
我不确定上述内容是否适用于特定值或指定键中的所有条目。
比较列表和 .reg
如果匹配,则根据需要运行 REG DELETE /f 或 REG DELETE /v /f 或 REG DELETE /va /f。
REG DELETE "HKCU\Software\Google\Chrome" /f
REG DELETE "HKLM\Software\Google\Chrome" /f
REG DELETE "HKCU\Software\Policies\Google\Chrome" /f
REG DELETE "HKLM\Software\Policies\Google\Chrome" /f
REG DELETE "HKLM\Software\Policies\Google\Update" /f
REG DELETE "HKLM\Software\WOW6432Node\Google\Enrollment" /f
REG DELETE "HKLM\Software\WOW6432Node\Google\Update\ClientState\{430FD4D0-B729-4F61-AA34-91526481799D}" /v CloudManagementEnrollmentToken /f
REG DELETE "HKLM\Software\WOW6432Node\Microsoft\Policies" /f
REG DELETE "HKLM\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Policies" /f
REG DELETE "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies" /f
REG DELETE "HKLM\Software\Microsoft\Windows\CurrentVersion\Policies" /f
REG DELETE "HKCU\Software\Microsoft\WindowsSelfHost" /f
REG DELETE "HKLM\Software\Microsoft\WindowsSelfHost" /f
REG DELETE "HKLM\Software\Microsoft\Policies" /f
REG DELETE "HKCU\Software\Policies" /f
REG DELETE "HKLM\Software\Policies" /f
REG DELETE "HKLM\Software\Policies\Microsoft\Windows Defender" /v DisableAntiSpyware /f
REG DELETE "HKLM\Software\Policies\Microsoft\Edge" /va /f
REG DELETE "HKLM\Software\Microsoft\Windows\CurrentVersion\WindowsStore\WindowsUpdate" /f
REG DELETE "HKLM\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\WindowsStore\WindowsUpdate" /f
- ECHO 到 cmd 和 %~dp0output.log 表明键/值/条目已被处理和删除
如果不存在..
- ECHO 到 cmd 和 %~dp0output.log 表明它不存在
"HKCU\Software\Google\Chrome" key does not exist
No entries can be found in "HKLM\Software\Policies\Microsoft\Edge"
Value DisableAntiSpyware cannot be found in "HKLM\Software\Policies\Microsoft\Windows Defender"
三.删除该批次创建的列表,但如果该列表已存在,则不删除。
IF EXIST "%ListFile%" ( DEL "%ListFile%" ) ELSE ( goto :eof )
我试图修改我找到的片段,但还不明白 for 循环是如何工作的,并且在某种程度上我只有一个列表,并且 for 循环将适应它是一个键,是一个值(/v )和/或仅需要处理指定键(/va)内的所有条目
下面的当前脚本到目前为止可以工作,但缺少上述所有要点。任何添加这些的帮助都是值得赞赏的。
REG DELETE "HKCU\Software\Google\Chrome" /f
REG DELETE "HKLM\Software\Google\Chrome" /f
REG DELETE "HKCU\Software\Policies\Google\Chrome" /f
REG DELETE "HKLM\Software\Policies\Google\Chrome" /f
REG DELETE "HKLM\Software\Policies\Google\Update" /f
REG DELETE "HKLM\Software\WOW6432Node\Google\Enrollment" /f
REG DELETE "HKLM\Software\WOW6432Node\Google\Update\ClientState\{430FD4D0-B729-4F61-AA34-91526481799D}" /v CloudManagementEnrollmentToken /f
REG DELETE "HKLM\Software\WOW6432Node\Microsoft\Policies" /f
REG DELETE "HKLM\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Policies" /f
REG DELETE "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies" /f
REG DELETE "HKLM\Software\Microsoft\Windows\CurrentVersion\Policies" /f
REG DELETE "HKCU\Software\Microsoft\WindowsSelfHost" /f
REG DELETE "HKLM\Software\Microsoft\WindowsSelfHost" /f
REG DELETE "HKLM\Software\Microsoft\Policies" /f
REG DELETE "HKCU\Software\Policies" /f
REG DELETE "HKLM\Software\Policies" /f
REG DELETE "HKLM\Software\Policies\Microsoft\Windows Defender" /v DisableAntiSpyware /f
REG DELETE "HKLM\Software\Policies\Microsoft\Edge" /va /f
REG DELETE "HKLM\Software\Microsoft\Windows\CurrentVersion\WindowsStore\WindowsUpdate" /f
REG DELETE "HKLM\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\WindowsStore\WindowsUpdate" /f
@RD /S /Q "%ProgramFiles(x86)%\Google\Policies"
@RD /S /Q "%WinDir%\System32\GroupPolicy"
@RD /S /Q "%WinDir%\System32\GroupPolicyUsers"
ECHO.
gpupdate /force
ECHO.
ECHO Complete. Will shutdown..
pause>nul
shutdown.exe /r /t 00
EXIT /B 0