我編寫了這個小批次腳本來幫助我自動清理 300 多台相同 PC 的註冊表中的一些非常特定的註冊表項。它一直運作到將關鍵變數傳遞給“reg delete %1”命令。
@echo off
C:
cd C:\Program Files\McAfee\Common Framework\
framepkg.exe remove=agent /silent
setlocal
for /F %%c in ('REG QUERY HKLM\SOFTWARE /s^|FIND "HKEY_"^|findstr /L /I /C:"mcafee"') do call :delete %%c
endlocal
goto :EOF
:delete
reg delete /f %1
pause
任何和所有調試幫助將不勝感激!
答案1
看起來最後reg delete
需要:/f
C:\TEMP>reg delete /f hkcu\test
ERROR: Invalid key name.
Type "REG DELETE /?" for usage.
C:\TEMP>reg delete hkcu\test /f
The operation completed successfully.