使用通配符删除registry项

我希望find一种方法来删除基于通配符使用batch file的registry项,而不是写一些VBScript。 有没有人有一个例子?

我不得不按照以下所述继续使用MS的精彩手动删除Office:

http://support.microsoft.com/kb/928218

我试图去除的一个例子是:

HKEY_CLASSES_ROOT\Installer\Products\*F01FEC HKEY_CLASSES_ROOT\Installer\UpgradeCodes\*F01FEC HKEY_CLASSES_ROOT\Installer\Win32Assemblies\*Office12*

可以reg查询将值放入一个variables,然后可能用for循环打他们?

 FOR %%i IN (%PATH1% %PATH2% %PATH3%) DO ( reg delete %PATH1% /f ) 

我分手了,写了一个VBScriptregistry清理似乎工作…

 On Error Resume Next const HKEY_LOCAL_MACHINE = &H80000002 const HKEY_CLASSES_ROOT = &H80000000 const HKEY_CURRENT_USER = &H80000001 strComputer = "." Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_ strComputer & "\root\default:StdRegProv") strKeyPath = "Software\Microsoft\Office\12.0" DeleteSubkeys HKEY_CURRENT_USER, strKeyPath strKeyPath = "Software\Microsoft\Office\12.0" DeleteSubkeys HKEY_LOCAL_MACHINE, strKeyPath strKeyPath = "SYSTEM\CurrentControlSet\Services\ose" Deletesubkeys HKEY_LOCAL_MACHINE, strKeyPath strKeyPath = "SOFTWARE\Microsoft\Office\Delivery\SourceEngine\Downloads" oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys For Each subkey In arrSubKeys If Not InStr(subkey, "0FF1CE}-") = 0 Then 'WScript.Echo subkey Deletesubkeys HKEY_LOCAL_MACHINE, strKeyPath & "\" & subkey End If Next strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys For Each subkey In arrSubKeys If Not InStr(subkey, "0FF1CE") = 0 Then 'WScript.Echo subkey Deletesubkeys HKEY_LOCAL_MACHINE, strKeyPath & "\" & subkey End If Next strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UpgradeCodes" oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys For Each subkey In arrSubKeys If Not InStr(subkey, "F01FEC") = 0 Then 'WScript.Echo subkey Deletesubkeys HKEY_LOCAL_MACHINE, strKeyPath & "\" & subkey End If Next strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products" oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys For Each subkey In arrSubKeys If Not InStr(subkey, "F01FEC") = 0 Then 'WScript.Echo subkey Deletesubkeys HKEY_LOCAL_MACHINE, strKeyPath & "\" & subkey End If Next strKeyPath = "Installer\Features" oReg.EnumKey HKEY_CLASSES_ROOT, strKeyPath, arrSubKeys For Each subkey In arrSubKeys If Not InStr(subkey, "F01FEC") = 0 Then 'WScript.Echo subkey Deletesubkeys HKEY_CLASSES_ROOT, strKeyPath & "\" & subkey End If Next strKeyPath = "Installer\Products" oReg.EnumKey HKEY_CLASSES_ROOT, strKeyPath, arrSubKeys For Each subkey In arrSubKeys If Not InStr(subkey, "F01FEC") = 0 Then 'WScript.Echo subkey Deletesubkeys HKEY_CLASSES_ROOT, strKeyPath & "\" & subkey End If Next strKeyPath = "Installer\UpgradeCodes" oReg.EnumKey HKEY_CLASSES_ROOT, strKeyPath, arrSubKeys For Each subkey In arrSubKeys If Not InStr(subkey, "F01FEC") = 0 Then 'WScript.Echo subkey Deletesubkeys HKEY_CLASSES_ROOT, strKeyPath & "\" & subkey End If Next strKeyPath = "Installer\Win32Assemblies" oReg.EnumKey HKEY_CLASSES_ROOT, strKeyPath, arrSubKeys For Each subkey In arrSubKeys If Not InStr(subkey, "Office12") = 0 Then 'WScript.Echo subkey Deletesubkeys HKEY_CLASSES_ROOT, strKeyPath & "\" & subkey End If Next Sub DeleteSubkeys(reghive, KeyPath) Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_ strComputer & "\root\default:StdRegProv") objReg.EnumKey reghive, KeyPath, arrrSubkeys If IsArray(arrrSubkeys) Then For Each strrSubkey In arrrSubkeys DeleteSubkeys reghive, KeyPath & "\" & strrSubkey Next End If objReg.DeleteKey reghive, KeyPath End Sub 

我想你使用REGEDIT,然后使用FIND通过列表(或得到一个GNU grep的Win32的端口和serach使用正则expression式)。 由于GUID的片段不是全局唯一的,因此您可能会轻微删除不属于Office的registry项的风险!

 @echo off set TEMPFILE=%TEMP%\%RANDOM%.REG set TODELETE=%TEMP%\%RANDOM%.REG regedit /e "%TEMPFILE%" HKEY_CLASSES_ROOT\Installer find "HKEY_CLASSES_ROOT\Installer\Products" "%TEMPFILE%" | find "C]" > "%TODELETE%" find "HKEY_CLASSES_ROOT\Installer\UpgradeCodes" "%TEMPFILE%" | find "C]" >> "%TODELETE%" find "HKEY_CLASSES_ROOT\Installer\Win32Assemblies" "%TEMPFILE%" | find "C]" >> "%TODELETE%" for /f "delims=[]" %%i in (%TODELETE%) do reg delete /f "%%i" del "%TEMPFILE%" del "%TODELETE%" :end