VBScript卸载软件

时间:2019-10-29 18:46:07

标签: vbscript

我正在尝试获取VBScript来卸载软件。当我运行它时,似乎只处理第一个匹配,然后结束。我有什么错,因为它没有遍历strPublisher中的每个sMatch实例?

sMatch = "Mitel Networks Corporation"
On Error Resume Next
Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set WshShell = CreateObject("Wscript.Shell")
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall"
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
For Each subkey In arrSubKeys
   strPublisher = ""
   strPublisher = WshShell.RegRead ("HKLM\" & strKeyPath & "\" & subkey & "\Publisher")
   If InStr(1, strPublisher, sMatch) >0 Then
      WshShell.Run "cmd /c C:\Windows\System32\msiexec.exe /X" & SubKey & " /L*V msilog.txt", 1, True
      WScript.Sleep 50000
   End If
Next

谢谢!

1 个答案:

答案 0 :(得分:0)

评论:
    错误返回下一个 并且您可能会得到导致该问题的错误。你得到什么错误?