Unable to uninstall a WiX Patch - wix

I am working on a Patch sample using the following link. However, I am not able to uninstall the patch either from Control Panel or from the command line MSIEXEC /i "MsiPath" MSIPATCHREMOVE="PathToMSP"
Peter Marcu's Blog: WiX: Building a Patch using the new Patch Building System - Part 3
Can anyone please let me know how to successfully uninstall or rollback a patch?
Note: I have set the AllowRemoval attribute to "yes" in the Patch.wxs file for the Patch element.

I would turn off logging, because apparently it's unable to perform the logging. Or try an explicit log location on your uninstall command line. Also, it could be this:
https://support.microsoft.com/en-us/help/2564571/-error-opening-installation-log-file--verify-that-the-specified-locate
and a detour is suggested.

Related

WiX : How to disable creating RestorePoint during installation at least on testing

When I run my WiX MSI installer it takes too long to get executed, when I checked the log, I found that the MSI create a Windows RestorePoint,
Question is : how to disable this, at least on testing environment, because it waste much time when testing.
MSIFASTINSTALL: You can use the MSIFASTINSTALL property. You can set it in the property table or via command line:
msiexec.exe /i MySetup.msi MSIFASTINSTALL=1
Other values you can try are 3 (no restore point and simple costing) and 7 (no restore point, simple costing and fewer progress messages).
See this previous answer as well: How can I speed up MSI package install and uninstall?

Wix FindRelatedProducts has found a product which is not installed

After testing many of install/uninstall of my product in the machine I've ended up a scenario where I don't have my product installed, at least I cannot see it in the control panel, but when I try to install it again, Wix is trying to Update a product which is not installed.
I've executed the msi with the logs, then I found that FindRelatedProducts is found a GUID and populating the WIX property WIX_UPGRADE_DETECTED.
part of the log:
FindRelatedProducts: Found application: {MY-GUID}
MSI (c) (24:8C) [07:21:36:885]: PROPERTY CHANGE: Adding WIX_UPGRADE_DETECTED property. Its value is '{MY-GUID}'.
As I'm using WIX_UPGRADE_DETECTED to select with dialog (Install or Upgrade) to show, It's showing a upgrade dialog, but no product is installed.
If I test in another machine, doing the same scenario, FindRelatedProducts doesn't find any product, which is the correct case.
I'm suspecting of some entry in the windows Registry(regedit) was not cleaned.
Do you know how Wix detects FindRelatedProducts? Or why Wix is populating the WIX_UPGRADE_DETECTED with no product installed?
Thanks!
Short Answer: The answer below is probably too elaborate, just do an uninstall of what your upgrade setup finds and then try to
install again.
From a command prompt (Windows Key + Tap R +
Type: cmd.exe + Enter) run the following command:
msiexec.exe /x {GUID-FROM-LOG-FILE}
The GUID is (most likely) the one from your log file: WIX_UPGRADE_DETECTED. Then try
installing again.
Failing Uninstall: If the uninstall fails, try running this Microsoft FixIt tool. Sometimes it can sort out setups that don't uninstall properly. Alternative, under the hood fix (not recommended).
UpgradeTable: The first thing I would do is to verify what is in the UpgradeTable in the compiled MSI file that shows the problem. Does the upgrade code there match the upgrade code for your setup? (UpgradeCode entry in the Property Table).
The content of the UpgradeTable determines what existing installations (if any) are detected as related to your new installation. If you configure weird stuff here you could even end up uninstalling competitive products erroneously detected as related to yours - I wouldn't try that :-). Too much paperwork.
Uninstall: Now, how to get rid of the problem installation? You need to get hold of the ProductCode GUID. There are numerous ways to obtain this information. It should be the product GUID you see in your MSI log for WIX_UPGRADE_DETECTED, so try that first:
msiexec.exe /x {GUID}
Here is an answer on uninstalling MSI setups in a general sense (all kinds of different options - have a quick read?): Uninstalling an MSI file from the command line without using msiexec.
ProductCode (GUID): Rob has already mentioned the right MSI API to list installed products, I will just add that I have this answer here that can help: How can I find the product GUID of an installed MSI setup? It lists several options to see what is installed on your box.
VBScript / COM Automation: I will just inline the VBScript option from the first link above (there are several options listed in that linked answer):
' 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")
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")
output.writeline (productcode & ", " & name & ", " & version)
Next
output.Close
PowerShell: Throwing in the PowerShell option as well. In some cases this can trigger unexpected self-repair.
get-wmiobject Win32_Product | Format-Table IdentifyingNumber, Name, LocalPackage -AutoSize
The Windows Installer has registration spread about the registry. It provides an API to introspect over that registration. In this case, you want ::MsiEnumRelatedProducts(). It will get you all the products related via that UpgradeCode.
You can then uninstall those products by doing:
msiexec /x {PRODUCT-CODE-GUID}
You should find {PRODUCT-CODE-GUID} is the same as what you redacted as {MY-GUID}.
Note: this has nothing to do with the WiX Toolset. Is 100% Windows Installer behavior (aka: MSI).
FindRelatedProducts is executed by Windows Installer not WiX. Your assertion that the behavior is incorrect is most certainly incorrect. You have a dirty machine and MSI has artifacts indicating that it's installed. Your other machine is clean and does not.
I was able to identify what were the registry entries left on the machine which was causing the errors that I mentioned.
They are in the following location:
- HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\UpgradeCodes\{OTHER-GUID}
- HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\Products\{OTHER-GUID}
Note that, the {OTHER-GUID} is not my product code, but a generated one, my product code is one of a values present into those registry entries.
Just removing them makes my installer working again.
Tks #stein-Åsmul this command: get-wmiobject Win32_Product is very helpful.

How can I know when installation is finished?

If I want to install msi on remote computer in quiet mode, an receive a confirmation if the installation completed successfully or did not succeeded.
I have tried to look for a solution in windows installer API but with no luck...
Is there an event or something like that?
I have found 3 options to validate installation.
From the installation log. Need to find "return value 3" - Error value.
The msiexec process will return exit code.
Using Microsoft.Deployment.WindowsInstaller.Dll.

Got error "DIRCA_CheckFX. Return value 3." while unInstalling a program

I created an installer project for Win XP using VS 2013.
While trying to install it, I got an error:
"DIRCA_CheckFX. Return value 3."
I visited this article in StackOverFlow: DIRCA_CHECKFX Return Value 3 - VS 2013 Deployment Project.
I did the Suggestion that I read there - to replace the "dpca.dll" - and it works great !
But only at machines that I didn't install the bad msi before.
While trying to install the new version of msi on a machine that has the bad version, I got an error that this program is already installed.
But while trying to uninstall the program - I got the error of : "DIRCA_CheckFX. Return value 3."
My question Is - How to Unistall the bad Version Of my installer and prevent this error?
thanks.
The root cause of this is the perhaps silly choice to do a check for the .NET Runtime when uninstalling the product. I suppose it's possible that someone uninstalled the .NET FW and that you are running uninstall custom actions that require it, and maybe that happened to you, but it seems unnecessary to me IMO.
If I were to have this problem, there are two solutions:
If you have that exact same MSI file, same version, ProductCode, identical in every way, then open it with Orca and go to the InstallExecuteSequence table. Go to the DIRCA_CheckFX call and set a condition of False, save the MSI file. Then install that MSI file with a command line msiexec /i [path to new MSI] REINSTALL=ALL REINSTALLMODE=vomus and this will do an update in place of the installed product, including the call to DIRCA_CheckFX that is now suppressed. Uninstall should work.
In the absence of the proper MSI file, troll through the Windows\installer folder looking at the cached MSI files. Hovering the mouse over each should get you to your cached MSI for the broken product. Again, edit with Orca as above to suppress the call on DIRCA_CheckFX.

Launch condition in WIX to check advertise mode

I am running my MSI from command prompt with /jm option. I want to add a LaunchCondition in my WIX file to check whether the MSI is triggered with /jm option.
Thanks in advance.
https://wixtoolset.org/documentation/manual/v3/xsd/wix/advertiseexecutesequence.html
Try using the AdvertiseExecuteSequence tag. You can create an error action to prevent any advertised installations from taking place. Just place the error at the beginning of the sequence.
Initialize the error action:
<CustomAction Id="ErrorMessageId" Error="Insert error message here"/>`
Run the error action:
<AdvertiseExecuteSequence>
<Custom Action="ErrorMessageId" Before="CostInitialize"/>
</AdvertiseExecuteSequence>
Every feature can go into advertised state. One easy way would be to edit the .msi, if possible and add the "msidbFeatureAttributesDisallowAdvertise" (8) and maybe the "msidbFeatureAttributesUIDisallowAbsent" (16) attribute to the MSI feature table. (I don't work with WiX so you will find out yourself).
Another way would be to add a custom action who controls if the ADVERTISE property is nonempty and just abort the installation.
Changing the feature action from advertise to install local would be quite tricky but maybe possible.
If you have a path (.msp) there are other ways to protect it from being installed with features in advertised mode.