代码没什么难度,就是利用WMI读取和删除注册表值。我加了许多与本专题无关的东西,因为我觉得有些初学者(包括我)可能用得到。
'Code By Coo_boi
'WMI on Registry
'...
On Error Resume Next
Dim oReg
Dim RootKey,strKeyPath
Const HKEY_LOCAL_MACHINE = &H80000002
'Const HKEY_CLASSES_ROOT = &H80000000
'Const HKEY_CURRENT_USER = &H80000001
'Const HKEY_Users = &H80000003
'Const HKEY_Current_Config = &H80000005
Const REG_SZ = 1
Const REG_EXPAND_SZ = 2
Const REG_BINARY = 3
Const REG_DWORD = 4
Const REG_MULTI_SZ = 7
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
RootKey=HKEY_LOCAL_MACHINE
strKeyPath="SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\RunMRU"
oReg.EnumValues HKEY_LOCAL_MACHINE,strKeyPath,arrValueNames,arrValueTypes
If Not IsNull(arrValueNames) Then
i=0
For Each ValueName In arrValueNames
strValue=GetValue(RootKey,strKeyPath,ValueName,arrValueTypes(i))
strTemp=strTemp & ValueName &":"& vbCrLf &" "& strValue & vbcrlf
i=i+1
Next
WScript.Echo strTemp
'delName=InputBox(strTemp,"Delete The Value","a")
'If Not IsNull(delName) Then
'DeleteValue RootKey,strKeyPath,delName
'End If
Else
WScript.Echo "Value Not Exist or Read Failed"
End If
Function GetValue(RootKey,strKeyPath,strValueName,ValueType)
Select Case ValueType
Case REG_SZ
oReg.GetStringValue RootKey,strKeyPath,strValueName,RetValue
Case REG_EXPAND_SZ
oReg.GetExpandedStringValue RootKey,strKeyPath,strValueName,RetValue
Case REG_BINARY
oReg.GetBinaryValue RootKey,strKeyPath,strValueName,RetValue
Case REG_DWORD
oReg.GetDWORDValue RootKey,strKeyPath,strValueName,RetValue
Case REG_MULTI_SZ
oReg.GetMultiStringValue RootKey,strKeyPath,strValueName,RetValue
End Select
GetValue=RetValue
End Function
Sub DeleteValue(RootKey,strKeyPath,strValueName)
oReg.DeleteValue RootKey,strKeyPath,strValueName
End Sub