问题
I'm creating a VBScript to remove all found instances of LogMeIn Software. It seems to work installing but it is leaving the registry key. If I run the string manually from the cmd prompt it completely uninstalls, including removing the registry key. What do I need to do to not just execute the MSI uninstall but to also clean up the registry? Thank You
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
回答1:
How many instances? Are they using the same upgrade code? You can uninstall all instances by the single upgrade code if so. Here is an example: Powershell: Uninstall application by UpgradeCode.
UPDATE: C# / .NET version.
There is also the Windows Installer PowerShell module from Heath Stewart.
Here is a proposed script inlined - I haven't tested it for reboot scenarios. Just leave the product open and uninstall and see if it triggers a reboot. Invoke via cscript.exe
for silent running:
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
来源:https://stackoverflow.com/questions/58308820/remove-all-versions-of-logmein-software