1

我正在尝试使用reg delete批处理命令删除注册表值。我遇到的问题是我无法删除该值。这是我正在尝试的:

REG DELETE "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ports\" /v C:\convertdoc\output\SilentPrintTemp\126017829image-gif3.ps

理想情况下,我想删除所有条目:

REG DELETE "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ports\" /v  C:\convertdoc\output\SilentPrintTemp\*.ps

我已经尝试了几种不同的方式和不同的参数。通常双“”在键的末尾停止命令。所以也许我的语法是错误的?

4

1 回答 1

1

编辑:

使用.bat扩展名保存并运行它:

@echo off
setlocal
set "ports=HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ports"

rem get only the first token of each line of "reg query"
for /f %%I in (
    'reg query "%ports%"'
) do (
    echo(%%I | findstr /i "c:\\convertdoc\\output\\silentprinttemp\\.*\.ps" >NUL && (
        rem (if "findstr" didn't exit with an abnormal error code)
        echo Deleting item %%I
        reg delete "%ports%" /v "%%I" /f
    )
)
于 2013-04-16T20:20:51.303 回答