我为此感到困惑。我希望找到一个密钥然后将其删除。我已注释掉删除内容进行测试,因为它会产生错误,如“ reg查询”行所示。
@echo off
for /f %%a in ('
reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" ^|
find "StartRCM"
') do (
set "regs=%%a"
)
echo %regs%
set key="HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\%regs%"
echo %key%
REM reg delete %key% /f
reg query %key%
输出为:
C:\>test2.bat
StartRCM
"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\StartRCM"
ERROR: The system was unable to find the specified registry key or value.
C:\>
编辑1
C:\>Reg Query "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server"
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server
StartRCM REG_DWORD 0x0
...
C:\>
答案 0 :(得分:1)
@echo off
for /f %%a in ('
reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" ^|
find "StartRCM"
') do (
set "regs=%%a"
)
echo "%regs%"
set "key=HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server"
echo %key%
if defined regs reg delete "%key%" /v "%regs%" /f
reg query "%key%"
您的初始代码,并调整了StartRCM
的值。
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server StartRCM REG_DWORD 0x0
从您的查询输出中:
StartRCM
是值。REG_DWORD
是数据类型。0x0
是数据。