Wix Run Custom Action When "Newer version is installed" - wix

How can I setup custom action to run my app when installation finished with "newer version is already installed"?
What I want: If newer version is installed, just run it. Run application always except deleting.
My configuration:
<CustomAction Id="LaunchApplication" Directory='INSTALLFOLDER' ExeCommand="[INSTALLFOLDER]\MyApp.exe"
Return="asyncNoWait" />
<InstallExecuteSequence>
<Custom Action="LaunchApplication" After="InstallFinalize">NOT (REMOVE="ALL")</Custom>
</InstallExecuteSequence>
Thanks

Solved with logs: app.msi /l*v log.txt
Working configuration:
<CustomAction Id="LaunchApplication" Directory='INSTALLFOLDER' ExeCommand="[INSTALLFOLDER]\MyApp.exe"
Return="asyncNoWait" />
<CustomAction Id="SetLaunchApplicationPath" Property="LaunchApplicationPath" Value="[ProgramFilesFolder][Manufacturer]\[ProductName]\MyApp.exe">
</CustomAction>
<CustomAction Id="LaunchApplicationOnDowngrade" ExeCommand="[SetLaunchApplicationPath]" Property="LaunchApplicationPath"
Return="asyncNoWait" />
<InstallUISequence >
<Custom Action="SetLaunchApplicationPath" After="FindRelatedProducts">WIX_DOWNGRADE_DETECTED</Custom>
<Custom Action="LaunchApplicationOnDowngrade" After="SetLaunchApplicationPath">LaunchApplicationPath</Custom>
</InstallUISequence>
<InstallExecuteSequence>
<Custom Action="LaunchApplication" After="InstallFinalize" >NOT (REMOVE="ALL")</Custom>
</InstallExecuteSequence>
Action LaunchApplication executes when install/update finished
Action LaunchApplicationOnDowngrade executes when install failed when newer version of product is found by FindRelatedProducts Action
I use <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." /> to configure upgrade.

Related

Wix - Run Batch File on Uninstall

So This CustomAction already work only for RunBatch ID, Running When Before Finalize Install. But It didn't work for uninstall, did i miss something ?
<CustomAction Id="RunBatch" ExeCommand="[INSTALLFOLDER]Tester.bat" Directory="INSTALLFOLDER" Execute="deferred" Return="asyncWait" />
<CustomAction Id="Uninstall" ExeCommand="[INSTALLFOLDER]Tester.bat" Directory="INSTALLFOLDER" Execute="deferred" Return="asyncNoWait"/>
<InstallExecuteSequence>
<Custom Action="RunBatch" Before="InstallFinalize">NOT Installed</Custom>
<Custom Action="Uninstall" Before="RemoveFiles">Installed</Custom>
</InstallExecuteSequence>
When I Run Uninstall from Installer or even control panel, batch file still not running...
I Fix It After Change
<Custom Action="Uninstall" Before="RemoveFiles">Installed</Custom>
to
<Custom Action="Uninstall" After="InstallInitialize">(NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")</Custom>

Installing TopShelf with WiX fails due to Admin Rights

So I am trying to install an application built using TopShelf, the application itself runs well and has no problems. The problem I run into is when I try to install the service. The TopShelf service is installed (from an administrator command line) using the myapp.exe install <options> instruction. I have wrapped the instruction in a custom action (see below). This runs, in that I can see a black box pop-up on install. The service fails to install, however. When I run the msi install from an administrator command line, the service installs correctly. I have included all Administrator related parameters in the WiX file (see below also). I am completely out of ideas and in need of help, can anyone see anything in the WiX files or does anyone have any idea what is preventing the service from installing?
What I have tried:
Topshelf - Custom Action in Wix Not Executing
Add Coffee and Shake Well - TopShelf
I have also tried wrapping the call to the topshelf app in a separate WiX custom Action project to execute and this also fails for the same reason.
<Product Id="*" Name="PackageName"
Language="1033"
Version="1.0.0.0"
Manufacturer="Manufacturer"
UpgradeCode="e7780903-3cf9-4ecc-b65a-45bc18b500df">
<Package InstallerVersion="200"
Compressed="yes"
InstallScope="perMachine"
InstallPrivileges="elevated"
Platform="x64" />
<Property Id="MSIUSEREALADMINDETECTION" Value="1" />
<MajorUpgrade AllowSameVersionUpgrades="yes"
DowngradeErrorMessage="A newer version of [ProductName] is already installed."
Schedule="afterInstallInitialize" />
<MediaTemplate EmbedCab="yes"/>
<Feature Id="ProductFeature" Title="FeatureName" Level="1">
<ComponentGroupRef Id="ProductComponents" />
</Feature>
<CustomAction Id="InstallService"
FileKey="MyApp.exe"
ExeCommand="install"
Impersonate="yes"
Execute="immediate" />
<CustomAction Id="StopService"
FileKey="MyApp.exe"
ExeCommand="stop"
Execute="immediate" />
<CustomAction Id="UninstallService"
FileKey="MyApp.exe"
ExeCommand="uninstall"
Execute="immediate" />
<InstallExecuteSequence>
<Custom Action="InstallService" After="InstallFinalize" >
NOT Installed AND NOT REMOVE
</Custom>
<Custom Action="StopService" After="InstallInitialize" >
(NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")
</Custom>
<Custom Action="UninstallService" After="StopService">
(NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")
</Custom>
</InstallExecuteSequence>
</Product>
There are a couple of problems with your custom actions. One is that the InstallService CA is immediate which means 1) It's before the files are installed and 2) it won't run with elevation. It needs to be deferred and before InstallFinalize.
If this is just an ordinary Windows service, then you should use a ServiceInstall node to install it (and uninstall it) as well as ServiceControl to stop, start, and delete it.
I solved this problem using the following code
<CustomAction Id="InstallService" FileKey="MyApp.exe" ExeCommand="install start" Impersonate="no" Execute="deferred" />
<CustomAction Id="UninstallService" FileKey="MyApp.exe" ExeCommand="stop uninstall" Impersonate="no" Execute="deferred" />
<InstallExecuteSequence>
<Custom Action="InstallService" Before="InstallFinalize">
NOT Installed AND NOT REMOVE
</Custom>
<Custom Action="UninstallService" Before="RemoveFiles">
(NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")
</Custom>
</InstallExecuteSequence>

How to add arguments to the custom action exe in Wix?

I am trying to execute an exe after installation. Below is how I am trying to do this.
<Property Id="WixShellExecTarget" Value="[#fil7D28AEF774656849395A2FA20A5C963D]" />
<CustomAction Id="LaunchMosquitto" BinaryKey="WixCA" DllEntry="WixShellExec" Impersonate="yes" />
<InstallExecuteSequence>
<Custom Action="LaunchMosquitto" After="InstallFinalize" />
</InstallExecuteSequence>
In here, [#fil7D28AEF774656849395A2FA20A5C963D] refers to the file ID. I need to run this exe with the parameter " -c config.conf". How can I achieve this? Any help would be much appreciated. I need this to happen without a command prompt being launched.
Logs after the answer :
MSI (s) (D0:24) [18:32:16:273]: Executing op: ActionStart(Name=LaunchMosquitto,,)
MSI (s) (D0:24) [18:32:16:273]: Executing op: CustomActionSchedule(Action=LaunchMosquitto,ActionType=3137,Source=BinaryData,Ta rget=WixQuietExec64,CustomActionData="C:\Kube2.0\Mosquitto\mosquitto.exe" -c C:\Kube2.0\Mosquitto\mosquitto.conf)
As Yan suggested you should use a quiet CA.
<SetProperty Id="LaunchMosquitto" Value=""[#fil7D28AEF774656849395A2FA20A5C963D]" -c config.conf" Before="LaunchMosquitto" Sequence="execute"/>
<CustomAction Id="LaunchMosquitto"
BinaryKey="WixCA"
DllEntry="WixQuietExec64"
Execute="deferred"
Return="check"
Impersonate="no"/>
<InstallExecuteSequence>
<Custom Action="LaunchMosquitto" Before="InstallFinalize" />
</InstallExecuteSequence>

Two simultaneous EXE files running WiX

I have two custom actions running two EXE files. But they get extracted at the same time and the processes block each other during install. How do I schedule them one after the other?
<CustomAction Id="StartAppOnExit1"
FileKey="UMIEXE"
ExeCommand=""
Execute="deferred"
Return="asyncNoWait"
Impersonate="no" />
<InstallExecuteSequence>
<Custom Action="StartAppOnExit1"
Before="InstallFinalize">$UMIEXE=3</Custom>
</InstallExecuteSequence>
<CustomAction Id="StartAppOnExit2"
FileKey="Python"
ExeCommand=""
Execute="commit"
Return="check"
Impersonate="no" />
<InstallExecuteSequence>
<Custom Action ="StartAppOnExit2"
After="StartAppOnExit1" >$Python=3</Custom>
</InstallExecuteSequence>
Here is my code, but I seem to be getting an error with what you told.
In product.wxs sequence them one after another and in custom action have a check to validate that the exe is executed and hold the process there only
<Custom Action="FirstCustomAction" After="InstallFinalize">NOT INSTALLED AND NOT REMOVE</Custom>
<Custom Action="SecondCustomAction" After="FirstCustomAction">NOT INSTALLED AND NOT REMOVE</Custom>
in CustomAction
WaitForExit() in process call.

Wix Open web page when uninstall completes

I'm using Wix3. I need to open a web page when the user uninstalls the product.
Any ideas how it can be done?
Thanks.
Here's a sample of the code we use, we don't actually set the URL at compile time, but update properties in the MSI post-build so this might seem a little "over engineered". We use the WiXShellExec CA and have an additional condition so that the webpage is only displayed during uninstall, and not during a major upgrade.
<Fragment>
<Property Id="MyURL"><![CDATA[http://www.blah.blah.blah/]]></Property>
<CustomAction Id="SetOpenURL" Property="WixShellExecTarget" Value="[MyURL]" />
<CustomAction Id="OpenURL" BinaryKey="WixCA" DllEntry="WixShellExec" Impersonate="yes" Return="ignore" />
<InstallExecuteSequence>
<!-- Launch webpage during full uninstall, but not upgrade -->
<Custom Action="SetOpenURL" After="InstallFinalize"><![CDATA[REMOVE ~= "ALL" AND NOT UPGRADINGPRODUCTCODE]]></Custom>
<Custom Action="OpenURL" After="SetOpenURL"><![CDATA[REMOVE ~= "ALL" AND NOT UPGRADINGPRODUCTCODE]]></Custom>
</InstallExecuteSequence>
</Fragment>
Add these XML elements somewhere under your <Product> element:
<CustomAction Id="LaunchBrowser"
ExeCommand="explorer.exe http://www.google.com"
Directory="INSTALLDIR"
Return="asyncNoWait" >
REMOVE="ALL"
</CustomAction>
<InstallExecuteSequence>
<Custom Action="LaunchBrowser" After="InstallValidate"/>
</InstallExecuteSequence>
The REMOVE="ALL" condition will make sure the custom action is executed only if the product is being completely removed.
The After="InstallValidate" makes sure that the custom action is executed right after the REMOVE property value becomes known.
The example provided by FireGiant Launch the Internet doesn't work for me but it inspire me to come out my own solution as below.
The condition NOT Installed mean new installation while Installed means it only trigger when uninstall.
<CustomAction Id="LaunchBrowser" Directory="INSTALLDIR" Return="asyncNoWait" ExeCommand="explorer.exe http://www.google.com/" />
<InstallExecuteSequence>
<Custom Action="LaunchBrowser" After="InstallFinalize">Installed</Custom>
</InstallExecuteSequence>
Here is what I did for both install and uninstall:
<Product>
...
<CustomAction Id="LaunchBrowserInstall" Directory="TARGETDIR" Execute="immediate" Impersonate="yes" Return="asyncNoWait" ExeCommand="explorer.exe https://www.example.com/post_install/" />
<CustomAction Id="LaunchBrowserUninstall" Directory="TARGETDIR" Execute="immediate" Impersonate="yes" Return="asyncNoWait" ExeCommand="explorer.exe https://www.example.com/post_uninstall/" />
<InstallExecuteSequence>
<Custom Action="LaunchBrowserInstall" After="InstallFinalize">NOT Installed AND NOT REMOVE</Custom>
<Custom Action="LaunchBrowserUninstall" After="InstallFinalize">REMOVE ~= "ALL"</Custom>
</InstallExecuteSequence>
...
</Product>