我正在创建VBScript来删除所有找到的LogMeIn软件实例。它似乎可以正常安装,但是保留了注册表项。如果我从cmd提示符下手动运行字符串,它将完全卸载,包括删除注册表项。我需要做什么,不仅要执行MSI卸载,还要清理注册表?谢谢
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
strDisplayName = WshShell.RegRead ("HKLM\" & strKeyPath & "\" & subkey
& "\Contact")
If InStr(1, strDisplayName, "LogMeIn") > 0 Then
' msgbox "C:\Windows\system32\msiexec.exe /norestart /X " & SubKey & "
/qn" ' Just for debugging
WScript.Sleep 20000
WshShell.Run "cmd /c C:\Windows\System32\msiexec.exe /X" & SubKey & "
/qn /L*V msilog.txt", 1, True
End If
Next
多少个实例?他们是否使用相同的升级代码?您可以通过单个升级代码来卸载所有实例。这是一个示例:Powershell: Uninstall application by UpgradeCode。
这里是内嵌的建议脚本-我尚未针对重启方案对其进行测试。只需保持产品打开并卸载,然后查看它是否会触发重新启动。通过cscript.exe
调用以静默运行:
Const msiUILevelNone = 2
Const msiInstallStateAbsent = 2
Set installer = CreateObject("WindowsInstaller.Installer")
'installer.UILevel = msiUILevelNone ' Disabled to prevent silent uninstall. Now the UAC prompt will show
' Uninstall Orca, replace upgrade code with yours
Set products = installer.RelatedProducts("{UPGRADE-GUID-GOES-HERE-000000000000}")
For Each product In products
' MsgBox "Product Code: " & product ' Show the product code found, if you want
' The following call when run silently with admin rights may reboot the system without warning!
' This is due to badly authored MSI packages - most packages will not trigger this problem.
installer.ConfigureProduct product, 0, msiInstallStateAbsent ' Uninstall product
' See text above for info on the newer ConfigureProductEx method.
Next
Set installer = Nothing
MsgBox "Finished" ' Just so we know the script ran if nothing found to uninstall