Sequencing a custom action in WiX before "LaunchConditions" - wix

Is it possible to sequence a custom action before "LaunchConditions"?
This is my custom action:
<CustomAction
Id="CA_vcAppRunning"
BinaryKey="vcShowMsg"
DllEntry="IsAppRunning"
Return="check"
Execute="immediate"/>
Sequenced in <InstallExecuteSequence/>
<Custom Action="CA_vcAppRunning" Before="LaunchConditions" />
I tried this, opened the MSI file in Orca and found that my custom action is sequenced at "99".
But when I tried to install, it never got called.
I want to schedule this before LaunchConditions as this custom action is supposed to set a property which is used in the LaunchCondition (if the application is running, exit the installer/updater).

Don't schedule it in before LaunchConditions, schedule it after FindRelatedProducts and then add a second custom action that blocks install based on the results from your first CA.
This is the same method used to prevent downgrading in many tutorials, e.g.
<CustomAction Id="CA_BlockOlderVersionInstall" Error="!(loc.LaunchCondition_LaterVersion)" />
<InstallExecuteSequence>
<LaunchConditions After="AppSearch" />
<Custom Action="CA_BlockOlderVersionInstall" After="FindRelatedProducts">
<![CDATA[NEWERVERSIONDETECTED]]>
</Custom>
</InstallExecuteSequence>
<InstallUISequence>
<LaunchConditions After="AppSearch" />
<Custom Action="CA_BlockOlderVersionInstall" After="FindRelatedProducts">
<![CDATA[NEWERVERSIONDETECTED]]>
</Custom>
</InstallUISequence>

Related

Wix - Running a deferred action after InstallFinalize

Reading the Wix help I see that "Deferred execution custom actions must come after InstallInitialize and come before InstallFinalize in the action sequence."
However I have to perform a database upgrade on a remote box which needs to be run with the user credentials so I have created an immediate action and set it to run after installFinalize. Subsequently, I need to run another custom action to start a windows service which reads values from the database, this requires elevated (system) permissions, so needs to be a deferred custom action. Which as the Wix help kindly explains to me that I cannot do.
Any help, tips or Wix tricks appreciated please
<CustomAction Id="LaunchServerUpgrade" FileKey="Config.exe" ExeCommand="/upgradeServer"
Return="ignore" Execute="deferred" Impersonate="no"/>
<CustomAction Id="LaunchServerDatabaseUpgrade" FileKey="Config.exe" ExeCommand=" /databaseupgrade"
Return="ignore" Execute="immediate"/>
<CustomAction Id="LaunchServerStartServices" FileKey="Config.exe" ExeCommand=" /startservices"
Return="ignore" Execute="deferred" Impersonate="no"/>
<InstallExecuteSequence>
<Custom Action="LaunchServerUpgrade" Before='InstallFinalize'>
<![CDATA[(SERVERCONFIGUPGRADE) AND NOT REMOVE)]]>
</Custom>
<Custom Action="LaunchServerDatabaseUpgrade" After='InstallFinalize'>
<![CDATA[(SERVERCONFIGUPGRADE) AND NOT REMOVE)]]>
</Custom>
<Custom Action="LaunchServerStartServices" After='InstallFiles'>
<![CDATA[(SERVERCONFIGUPGRADE) AND NOT REMOVE)]]>
</Custom>
</InstallExecuteSequence>

Immediate Execute of many Files after InstallInitialize

I want do execute many files after InstallInitialize but not deferred, because I can have no admin rights. Till now I used for one file the example of the documentation:
<Property Id="QtExecCmdLine" Value="command line to run"/>
<CustomAction Id="QtExecExample" BinaryKey="WixCA" DllEntry="CAQuietExec" Execute="immediate" Return="check"/>
<InstallExecuteSequence>
<Custom Action="QtExecExample" After="TheActionYouWantItAfter"/>
</InstallExecuteSequence>
But the problem is, that there is only one QtExecCmdLine property and I want to execute more files.
The only way I see is to use the deferred example from the documentation with two custom actions.
If the files you want to run change your system you must run them after InstallInitialize and before InstallFinalize.
You can set the Impersonate attribute to “yes” to run them as user who lunched the installer instead of the System user account
To run multiple executable files after Installinitialize:
1) Create CustomAction for each of them
<Fragment>
<CustomAction Id="MYEXE1"
FileKey="myexe1.exe"
ExeCommand="-u"
Execute="rollback"
Impersonate="yes"
Return="check">
</CustomAction>
<CustomAction Id="MYEXE2"
FileKey="myexe2.exe"
ExeCommand="-i"
Execute="deferred"
Impersonate="yes"
Return="check">
</CustomAction>
</Fragment>
2)Schedule the custom
<InstallExecuteSequence>
<Custom Action="MYEXE1" After="InstallInitialize">
<![CDATA[NOT Installed]]>
</Custom>
<Custom Action="MYEXE2" After="myexe1">
<![CDATA[NOT Installed]]>
</Custom>
</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. Rollback custom action when is canceled installation

I have a custom action
<CustomAction Id="myActionId" BinaryKey="myAction" DllEntry="MySimpleAction" Execute="immediate" Return="check" />
<InstallExecuteSequence>
<Custom Action="myActionId" After="InstallInitialize">CHECKBOXCOPYPROP=1</Custom>
</InstallExecuteSequence>
My custom action does backup and resolved database. I need to do rollback (drop database) when is canceled installation.
I did:
<CustomAction Id="myActionId" BinaryKey="myAction" DllEntry="MySimpleAction" Execute="immediate" Return="check" />
<CustomAction Id="myActionRollbackId" BinaryKey="myActionRollback" DllEntry="MySimpleAction" Execute="rollback" Return="check" />
<InstallExecuteSequence>
<Custom Action="myActionId" After="InstallInitialize">CHECKBOXCOPYPROP=1</Custom>
<Custom Action="myActionRollbackId" Before="myActionId">CHECKBOXCOPYPROP=1</Custom>
</InstallExecuteSequence>
But I was having an error.
If I do like this:
<CustomAction Id="myActionId" BinaryKey="myAction" DllEntry="MySimpleAction" Execute="immediate" Return="check" />
<CustomAction Id="myActionRollbackId" BinaryKey="myActionRollback" DllEntry="MySimpleAction" Execute="immediate" Return="check" />
<InstallExecuteSequence>
<Custom Action="myActionId" After="InstallInitialize">CHECKBOXCOPYPROP=1</Custom>
<Custom Action="myActionRollbackId" After="myActionId">CHECKBOXCOPYPROP=1</Custom>
</InstallExecuteSequence>
My custom action myActionRollbackId works.
How to run rolback when is canceled installation?
Someone can help me?
The custom action which runs on install and does something with the database should be deferred (Execute='deferred'). Its corresponding rollback action should be Execute='rollback'. When you schedule these custom actions, the rollback action should go first.
Also, make sure the conditions are set properly.
Installation is always done in transaction. when you launch an installer, it first creates something called installation script which is like a to do list of what it will do while installation.
When we set some custom action as Execute="immediate", it gets executed immediately but when we set our action as Execute="deferred", it gets added in the installation script, hence rollback becomes easy for this.
Now one thing to note here is that we get access to session in Execute="immediate" mode, but we cannot access session in Execute="deferred" mode.
If we try to access session it will give error, which in this case might be the reason for your error...

When can I get the target directories in a WIX installer?

So I have a custom action
<CustomAction Id="GetTarget"
BinaryKey="CA"
DllEntry="GetTargetPath"
Execute="immediate"
Return="check"
HideTarget="no"
Impersonate="no" />
<InstallExecuteSequence>
<Custom Action="GetTarget" After="CostFinalize">(NOT REMOVE = "ALL")</Custom>
</InstallExecuteSequence>
This is calling a DLL that calls the method session.GetTargetPath("TARGETPATH"); But I get an exception "The directory name is invalid. TARGETPATH". I have the custom action as After="CostFinalize" as this is what I read from a source (which I can provide) but I think there is a mistake and I think that I just have to to execute the action at the right time.
I think you meant TARGETDIR. Take a look at http://msdn.microsoft.com/en-us/library/windows/desktop/aa371685(v=vs.85).aspx