Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
558 views
in Technique[技术] by (71.8m points)

wix - After using msiexec to uninstall a program it remains in the control panel (add/remove programs)

This seems really odd. I have a program installed (via a WiX installer) and I'm trying to uninstall it programatically (using c#) so I use msiexec.exe /x{product-code-GUID}. The program is uninstalled but it still shows in the control panel (add/remove programs). When I look in the registry I see the program under HKLMSOFTWAREWOW6432NodeMicrosoftWindowsCurrentVersionUninstall, but it's not under the GUID that this product has as its product code. It's under a seemingly random GUID that doesn't even exist in the .msi. Anyone know why and how I can tell what the GUID will be so that I can programtically remove it?

I guess I could install each version that I need to uninstall and inspect the registry and use the GUID that's there. That will work, but I want to understand why the GUID doesn't match the Product Code.


UPDATE 2-15-19 9:21am PT:

OK - I logged the uninstall and here's the end of the log. It seems to have completed successfully and yet it still appears in Control Panel:

MSI (s) (10:E4) [09:16:22:812]: Note: 1: 1724 
MSI (s) (10:E4) [09:16:22:812]: Product: Product Name -- Removal completed successfully.

MSI (s) (10:E4) [09:16:22:812]: Windows Installer removed the product. 
Product Name: Product Name. Product Version: 1.21.4. Product Language: 1033. 
Manufacturer: . Removal success or error status: 0.

MSI (s) (10:E4) [09:16:22:870]: Deferring clean up of packages/files, if any 
exist
MSI (s) (10:E4) [09:16:22:870]: MainEngineThread is returning 0
MSI (s) (10:80) [09:16:22:871]: RESTART MANAGER: Session closed.
MSI (s) (10:80) [09:16:22:871]: No System Restore sequence number for this 
installation.
=== Logging stopped: 2/15/2019  9:16:22 ===
MSI (s) (10:80) [09:16:22:892]: User policy value 'DisableRollback' is 0
MSI (s) (10:80) [09:16:22:892]: Machine policy value 'DisableRollback' is 0
MSI (s) (10:80) [09:16:22:892]: Incrementing counter to disable shutdown. 
Counter after increment: 0
MSI (s) (10:80) [09:16:22:892]: Note: 1: 1402 2: 



HKEY_LOCAL_MACHINESoftwareMicrosoftWindowsCurrentVersionInstallerRollbackScripts 3: 2 
MSI (s) (10:80) [09:16:22:894]: Note: 1: 2265 2:  3: -2147287035 
MSI (s) (10:80) [09:16:22:894]: Note: 1: 1402 2: HKEY_LOCAL_MACHINESoftwareMicrosoftWindowsCurrentVersionInstallerRollbackScripts 3: 2 
MSI (s) (10:80) [09:16:22:894]: Decrementing counter to disable shutdown. If counter >= 0, shutdown will be denied.  Counter after decrement: -1
MSI (s) (10:80) [09:16:22:894]: Post-install cleanup: removing installer file 'C:WindowsInstallerc8de6843.msi'
MSI (s) (10:80) [09:16:22:896]: Post-install cleanup: removing installer file 'C:WindowsInstaller{2DE751D3-33F4-4C3E-BD12-63E7F7F0A3C9}icon.ico'
MSI (s) (10:80) [09:16:22:896]: Post-install cleanup: removing installer folder 'C:WindowsInstaller{2DE751D3-33F4-4C3E-BD12-63E7F7F0A3C9}' (if empty)
MSI (s) (10:80) [09:16:22:896]: Note: 1: 2318 2:  
MSI (s) (10:80) [09:16:22:897]: Destroying RemoteAPI object.
MSI (s) (10:B4) [09:16:22:897]: Custom Action Manager thread ending.
MSI (c) (78:7C) [09:16:22:898]: Decrementing counter to disable shutdown. If counter >= 0, shutdown will be denied.  Counter after decrement: -1
MSI (c) (78:7C) [09:16:22:898]: MainEngineThread is returning 0
=== Verbose logging stopped: 2/15/2019  9:16:22 ===
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The Actual Solution (after debugging):

Run: C:ProgramDataPackage Cache{Product-GUID}ProductSetup.exe /uninstall /quiet


Duplicate Installation: You probably have a duplicate installation. Unless you accidentally left the Add / Remove Programs applet open during uninstall in which case you should close and reopen it to verify that the entry is still present.

"Noise": You could also have an issue with too many packages present to see that your setup.exe has installed as two separate MSI files. To prevent this, test on a clean virtual and check the Add / Remove Programs list well for other, related entries.

Product Code: You can find the product codes and product names for all products installed by using one of the methods described here: How can I find the product GUID of an installed MSI setup? Maybe try the PowerShell one-liner, or the VBScript.

Rollback: Note that an MSI can rollback its uninstall if a custom action fails during uninstall. This means that the rollback becomes a re-install or at least a recovery of the files that the uninstall removed. So in this scenario it looks like the uninstall ran, but the product was recovered due to a failing custom action. So the uninstall never "committed".

Uninstall: And here are several ways to uninstall MSI packages: Uninstalling an MSI file from the command line without using msiexec. When you have uninstalled all entries I would expect the ARP entry to be gone. Is this your own package? Duplicate installations are very common in such cases as a by-product of rapid test cycles.


Packed GUIDs: The GUIDs you find in the registry are generally packed, or in other words not formatted the same way as in your MSI.

Sample GUID Conversion:

HKEY_CLASSES_ROOTInstallerProducts

Packed GUID: 0076C0A639AEC2738817CDFC311D064A
Normal GUID: {6A0C6700-EA93-372C-8871-DCCF13D160A4}

Here are more details:

The latter link has a VBScript to convert Packed GUIDs to normal GUIDs.


LocalPackage: There is a local package cached on all systems when an MSI is installed. It will be located in %SystemRoot%Installer. You can use this to locate the file, and you can then right click it in Windows Explorer and select "Uninstall".

The idea here is not to use this as your main approach, but to determine if there is a hidden MSI that you also need to uninstall to get rid of everything from ARP.

Here is a VBScript to show the LocalPackage path (create VB script file on desktop, save and double click. Look for output msiinfo.csv - double click and import to Excel or equivalent - or notepad):

' Retrieve all ProductCodes (with ProductName and ProductVersion)
Set fso = CreateObject("Scripting.FileSystemObject")
Set output = fso.CreateTextFile("msiinfo.csv", True, True)
Set installer = CreateObject("WindowsInstaller.Installer")

output.writeline ("Product Code,Product Name,Product Version,Local Package")

On Error Resume Next ' we ignore all errors

For Each product In installer.ProductsEx("", "", 7)
   productcode = product.ProductCode
   name = product.InstallProperty("ProductName")
   version=product.InstallProperty("VersionString")

   local=product.InstallProperty("LocalPackage")

   output.writeline (productcode & ", " & name & ", " & version & ", " & local)
Next

output.Close

Similar Answers:


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...