Wix CloseApplication error - wix

I wrote an installer with wix 3.9 and it should close my App, if it is opened, during installation.
Following many examples, I wrote this code:
<util:CloseApplication
Id="CloseApp"
CloseMessage="yes"
Description="Close [ProductName] to continue installation"
RebootPrompt="yes" Target="[ProductName].exe"/>
<InstallExecuteSequence>
<Custom Action="DIRCA_TARGETDIR"
Before="CostInitialize"><![CDATA[TARGETDIR = ""]]></Custom>
<Custom Action="WixCloseApplications"
Before="InstallValidate"></Custom>
</InstallExecuteSequence>
But when I run my .msi, it fails and log says:
Action 15:54:34: WixCloseApplicationsDeferred.
Action start 15:54:34: WixCloseApplicationsDeferred.
MSI (s) (A0!94) [15:54:34:804]: Note: 1: 2762
DEBUG: Error 2762: Unable to schedule operation. The action must be scheduled between InstallInitialize and InstallFinalize.
What's wrong?

Related

WiX Toolset - issues running cmd in Custom Action

I'm trying to add a custom action that will delete files from the installation folder using the following code:
<CustomAction Id="InstallService" Return="check" Impersonate="no" Execute="deferred" Directory="INSTALLFOLDER" ExeCommand='cmd.exe /C del /s /q "[INSTALLFOLDER]"'/>
<InstallExecuteSequence>
<Custom Action="InstallService" Before ="InstallFiles">NOT Installed AND NOT REMOVE</Custom>
</InstallExecuteSequence>
This works on some computers but fails on others showing a message
A program required for install to complete could not be run.
And in the installation logs I see
Error 1721. There is a problem with this Windows Installer package. A program required for this install to complete could not be run. Contact your support personnel or package vendor
Any idea why this might happen or how to make it work?

Can Windows installer install two msi files at the same time? [duplicate]

This question already has answers here:
Wix and .NET Framework (prerequisites)
(5 answers)
Closed last month.
I have a msi installation package made by WIX, which automatically installs IIS Express 10.0 after the installation.
<Binary Id="myCustomActionsDLL" SourceFile="$(var.CustomAction.TargetDir)CustomAction.CA.dll" />
<CustomAction Id="CheckIISExpressStatus" BinaryKey="myCustomActionsDLL" DllEntry="CheckIISExpressStatus" Execute="immediate" Return="check" Impersonate="yes"/>
<CustomAction Id="InstallIISExpress" BinaryKey="myCustomActionsDLL" DllEntry="InstallIISExpress" Execute="immediate" Return="ignore" Impersonate="yes" />
<InstallExecuteSequence>
<Custom Action="CheckIISExpressStatus" After="InstallFinalize" Overridable="yes">NOT Installed</Custom>
<Custom Action="InstallIISExpress" After="CheckIISExpressStatus" Overridable="yes">NOT Installed AND IS_INSTALL_IISEXPRESS="1"</Custom>
</InstallExecuteSequence>
In the InstallIISExpress action, I call bat to perform the installation.
msiexec /i iisexpress_amd64_en-US.msi /qb
But during execution, the Windows Installer prompts the error:
Other programs are being installed, please wait for the installation to complete, and then try again to install the software.
What parameters can I set to allow msi to install two msi at the same time?
You must not run other setups from a custom action within your main MSI. Instead you should run MSI files in sequence using a bootstrapper such as WiX's Burn feature.
It is late. I tried to write a proper explanation of this at one point, maybe see if it makes sense to you: Wix - How to run/install application without UI.
To summarize: running legacy setup.exe files from a custom action in your MSI will not be reliable, and running MSI files - whether directly or embedded in a setup.exe will positively not work because Windows Installer does not allow concurrent MSI installation sequences. A mutex is set when InstallExecuteSequence runs, and no other InstallExecuteSequence can be run while it is in effect. Concurrent MSI installations are forbidden and technically impossible.

Run wix custom action before installing files

I should need to run a C++ wix custom action before file installation starts. Is it possible?
My code is
<InstallUISequence>
<Custom Action ="_EE10247D_B1B7_42F9_8BC9_A973E5755689" Before ="InstallFiles"></Custom>
</InstallUISequence>
<CustomAction Id="_EE10247D_B1B7_42F9_8BC9_A973E5755689" Execute="deferred" Impersonate="no" FileKey="FileDllId" adx:VSName="GuidAutoGen" DllEntry="GuidAutoGen" />
but the error message is "error LGHT0094: Unresolved reference to symbol 'WixAction:InstallUISequence/InstallFiles' in section 'Product:{C095BA7A-0E1E-4679-AAC0-3C17C82BC5EA}"
What's wrong?
Linker tells you absolutely true. "InstallUISequence" has no step "InstallFiles". This step presented in another sequence, "InstallExecuteSequence". This sequence executes after InstallUISequence.
In your case, you should write instead of your code:
<InstallExecuteSequence>
<Custom Action ="_EE10247D_B1B7_42F9_8BC9_A973E5755689" Before ="InstallFiles"></Custom>
</InstallExecuteSequence>
Well yes, you just sequence it before the InstallFiles action, in deferred mode. You might need to expand your question if you need more detail.

WIX Custom Action is not Executing during Upgrade

I am unable to execute custom action during Upgrade.It is giving the following error in logs.
Error 1721. There is a problem with this Windows Installer package. A program required for this install to complete could not be run. Contact your support personnel or package vendor. Action: CA_DFADMINWSPUPGRADE, location: E:\DealFoundrySetUp\, command: "E:\DealFoundrySetUp\PSScripts\UpdateAminWSP.bat" "Admin.wsp" "E:\DealFoundrySetUp\DFAdmin\AdminWsp\Admin.wsp"
MSI (s) (74:B4) [17:03:11:416]: Product: DealFoundry -- Error 1721. There is a problem with this Windows Installer package. A program required for this install to complete could not be run. Contact your support personnel or package vendor. Action: CA_DFADMINWSPUPGRADE, location: E:\DealFoundrySetUp\, command: "E:\DealFoundrySetUp\PSScripts\UpdateAminWSP.bat" "Admin.wsp" "E:\DealFoundrySetUp\DFAdmin\AdminWsp\Admin.wsp"
<CustomAction Id="CA_DFADMINWSPUPGRADE" Impersonate="no"
ExeCommand='"[INSTALLDIR_UG]PSScripts\UpdateAminWSP.bat" "[PRO_ADMINWSPNAME_UG]" "[PRO_ADMINWSPPATH_UG]"'
Directory="INSTALLDIR" Execute="deferred" Return="check" />
INSTALLDIR_UG value i am saving in Registry and during installation and using while Upgrade
<Property Id="INSTALLDIR_UG">
<RegistrySearch Id="rsDFInstallDirectory"
Name="DFInstallDirectory"
Root="HKLM"
Key="SOFTWARE\VALUEMOMENTUM\DEALFOUNDRY\DealFoundryAdmin"
Type="raw"
Win64="yes">
</RegistrySearch>
</InstallExecuteSequence>
<Custom Action="CA_DFADMINWSPUPGRADE" After="InstallFiles">
<![CDATA[INSTALL_DFUSERMANAGEMENT=1 AND (OLDER_VERSION_FOUND)]]>
</Custom>
</InstallExecuteSequence>
Any one help me plz.
Try switching to Impersonate="yes" i think your script might not execute as Local System.

"Installed" condition is always true when installing or uninstalling in WiX

I have a WiX installer which does some work, and at the end, launch RSYNC installer (it's an EXE file, no problem to have both working at same time).
But when uninstalling, I want to remove RSYNC too.
<CustomAction Id="InstallRSyncDaemon" FileKey="cwRsyncServer_4.0.5_Installer.exe" ExeCommand="/q" Execute="deferred" Return="ignore" Impersonate="no" />
<CustomAction Id="UninstallRSyncDaemon" FileKey="rsync_uninstall.bat" ExeCommand="[INSTALLDIR]" Execute="deferred" Return="check" Impersonate="no" />
<CustomAction Id="EditConf" FileKey="rsync.bat" ExeCommand="[INSTALLDIR]" Execute="deferred" Return="ignore" Impersonate="no"/>
<InstallExecuteSequence>
<Custom Action='InstallRSyncDaemon' Before='InstallFinalize'>(NOT remove="ALL")</Custom>
<Custom Action='EditConf' After='InstallRSyncDaemon'>(NOT remove="ALL")</Custom>
<Custom Action='UninstallRSyncDaemon' Before='RemoveFiles'>remove="ALL"</Custom>
</InstallExecuteSequence>
My problem is that during uninstalling, the Custom Action 'UninstallRSyncDaemon' is skipped:
MSI (s) (58:78) [17:37:40:475]: Skipping action: UninstallRSyncDaemon (condition is false)
I have tried with "installed" and other conditions, with the same result.
At the beginnning of the log file, I have:
MSI (c) (9C:80) [17:37:36:772]: PROPERTY CHANGE: Adding ACTION property. Its value is 'INSTALL'.
MSI (c) (9C:80) [17:37:36:772]: Doing action: INSTALL
Action 17:37:36: INSTALL.
Action start 17:37:36: INSTALL.
MSI (c) (9C:80) [17:37:36:772]: UI Sequence table 'InstallUISequence' is present and populated.
MSI (c) (9C:80) [17:37:36:772]: Running UISequence
MSI (c) (9C:80) [17:37:36:772]: PROPERTY CHANGE: Adding EXECUTEACTION property. Its value is 'INSTALL'.
If I try to change to the condition to launch it during installation, it is working, so for me it is just the statement of the condition.
But I do not understand why, this is the condition always used in a tutorial or in an answer on Stack Overflow.
I think the remove should be in upper case. Try this.
REMOVE="ALL"
But it will run in modify and Upgrade also. Check more about this condition here.