标题: [问题求助] 请教如何自动搜索并删除注册表含某关键词的项或键? [打印本页]
作者: suchost 时间: 2015-9-25 15:31 标题: 请教如何自动搜索并删除注册表含某关键词的项或键?
请高手指教,比如我要搜索MSOUC.EXE,并删除与之关联的所有项
作者: yu2n 时间: 2015-9-25 22:42
参考:
- '枚举注册表项及值
- Const HKEY_LOCAL_MACHINE = &H80000002
- Dim regWMI, FSO, Text
- Set FSO = CreateObject("Scripting.FileSystemObject")
- Set regWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
- Dim regRoot, regPath, regStr
- regRoot = HKEY_LOCAL_MACHINE
- regPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Run"
- FSO.OpenTextFile("RegList.txt", 2, True).Write "HomePath:HKEY_LOCAL_MACHINE" & regPath & vbCrLf & vbcrlf & "RegList:" & vbCrLf
- Set Text = FSO.OpenTextFile("RegList.txt", 8, True)
- GetValues regPath
- GetKeys regPath
- Set FSO = Nothing
- Set regWMI = Nothing
- CreateObject("Wscript.Shell").run "cmd /cRegList.txt", True, False
-
- Function GetKeys(Path)
- 'Text.WriteLine path & vbCrLf
- Dim arrRegKeys, regKey
- regWMI.Enumkey regRoot, path, arrRegKeys
- For Each regKey In arrRegKeys
- On Error Resume Next
- newpath = path & "\" & regKey
- GetValues newpath
- GetKeys newpath
- Next
- End Function
-
- Function GetValues(path)
- Dim regValue, arrRegNames, arrValueTypes, arrRegValues, Multi, regValueType
- regWMI.EnumValues regRoot, path, arrRegNames, arrValueTypes
- For i = 0 To UBound(arrRegNames)
- If Len(arrRegNames(i)) > 0 Then
- Multi = vbNullString
- Select Case arrValueTypes(i)
- Case 1
- regWMI.GetStringValue regRoot, path, arrRegNames(i), regValue
- regValueType = "REG_SZ"
- Case 2
- regWMI.GetExpandedStringValue regRoot, path, arrRegNames(i), regValue
- regValueType = "REG_EXPAND_SZ"
- Case 3
- regWMI.GetBinaryValue regRoot, path, arrRegNames(i), regValue
- regValueType = "REG_BINARY"
- Case 4
- regWMI.GetDwordValue regRoot, path, arrRegNames(i), regValue
- regValueType = "REG_DWORD"
- Case 7
- regWMI.GetMultiValue regRoot, path, arrRegNames(i), arrRegValues
- regValueType = "REG_MULTI_SZ"
- Multi = "yes"
- End Select
- If Multi = "yes" Then
- For Each str In arrRegValues
- regValue = regValue & str & vbTab
- Next
- End If
- newpath = Replace(path, regPath, "")
- If Left(newpath, 1) = "\" Then newpath = Mid(newpath,2,Len(newpath))
- Text.WriteLine newpath & arrRegNames(i) & vbTab & regValueType & vbTab & regValue
- End If
- Next
- End Function
复制代码
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |