当我尝试删除 .bat 文件中的注册表项时出现错误:
%SystemRoot%\System32\reg.exe delete "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\UFH\SHC" /v " 69 REG_MULTI_SZ C:\ProgramData\Microsoft\Windows\Start Menu\Programs\UltraVNC\UltraVNC Server Settings.lnk\0C:\Program Files\uvnc bvba\UltraVNC\uvnc_settings.exe" /f
我收到的错误是:
ERROR: The system was unable to find the specified registry key or value.
我正在以具有管理员权限的用户身份运行它,并且以管理员身份运行它。
答案1
我已经找到了我的命令行的答案。
@Echo Off
Set "Key=HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\UFH\SHC"
Set "Str=uvnc bvba"
setlocal EnableExtensions DisableDelayedExpansion
If exist %~dpn0.txt del %~dpn0.txt
If exist %~dpn0Str.txt del %~dpn0Str.txt
for /F "tokens=1,2*" %%A in ('@%SystemRoot%\System32\reg.exe query "%Key%" /v * ^| find "%Str%"') DO @(Echo=@%SystemRoot%\System32\reg.exe delete "%Key%" /v "%%A" /f
if not errorlevel 1 echo Deleted "%%A" from "%Key%" >>%~dpn0.txt
echo %%C >>%~dpn0Str.txt
)
endlocal
cmd /k
这给了我 %%A 中的子项名称 这给了我 %%C 中的子项数据
Note: Echo= before the reg delete needs to be removed for it to execute
Note: This must be run as administrator