WIX - How to launch readme and exe at the end of the installation - wix

I've read the WIX instructions here:
However, I want to launch the readme and the application which doesn't appear to be supported. Also the solution provided by the WIX documentation does not automatically check the option on the final screen. Does anyone know how to do this?

This sample code will help you to launch exe or open .txt file after MSI Install.
You can do some hacks and add it to UI. If launch box is checked it will launch specific exe or do action whichever you state there.
Below one without any UI launch whiechever exe you provide it to launch.
<InstallExecuteSequence>
<Custom Action='LaunchInstalledExe' After='InstallFinalize'/>
</InstallExecuteSequence>
<CustomAction Id="LaunchInstalledExe"
FileKey="ExeFile"
ExeCommand=""
Execute="immediate"
Impersonate="yes"
Return="asyncNoWait" />

Related

How to stop application automatically before running of uninstallation procedure?

In my installation package I have tool which allows to stop my main application.
I need to run this tool automatically during uninstallation of my application.
I created custom action and start it before or after InstallInitialize.
But it did not help.
Message "The following applications should be closed before continuing the install" still appears.
And script executes only when I click on the button OK in that dialog.
How to start custom action before notification "The following applications should be closed before continuing the install"?
Custom stop action before InstallValidate does not help by some reason.
<InstallExecuteSequence>
<Custom Action='StopApplication' Before="InstallValidate"/>
</InstallExecuteSequence>
<CustomAction Id="StopApplication"
FileKey="stopServer.cmd"
ExeCommand=""
Execute="immediate"
Impersonate="yes"
Return="ignore" />
Detection of apps that need closing down is done by the InstallValidate action, so you need to have your CA before that. After InstallInitialize is too late. That means it needs to be marked immediate.
p.s. WiX has a util CloseApp for this that might work for that app.

MSI Installer: Help running a UI based EXE with a CustomAction from a service based installer

I have created a MSI installer package using Wix Toolset 3.8 that is run by a third party installer service running under the "SYSTEM" account. My issue is that when trying to launch and run an installed executable from my MSI installer using a custom action, it also runs under the SYSTEM account instead of the administrator account that is currently logged in. I have spent hours researching on the net and from what I have read, specifying Impersonate="yes" will run that particular custom action under the account that launched the installer, but there lies the issue. Since the third party installer service is running from the SYSTEM account, specifying Impersonate="yes" would just run the custom action under the SYSTEM account as well correct? At least that's what my tests have shown. A little bit of background on my MSI installer:
InstallScope="perMachine"
<CustomAction Id="StartAction"
Directory="FOLDER"
ExeCommand ='cmd.exe /c start MYEXE.exe /tray'
Execute="immediate"
Impersonate="yes"
Return="check"/>
<InstallExecuteSequence>
<Custom Action='StartAction' Before='InstallFinalize'>NOT Installed</Custom>
</InstallExecuteSequence>
I have tried both "deferred" and "immediate" for Execute as well as setting "Impersonate" to both yes and no. Is there any way to make this work? I thought about using the runas command but I wouldn't know the password of the user account that initiated the install.
Thanks!
What is the EXE file doing? Do you have control of the application so you can move the logic from that external EXE into the main application's launching logic?
Other than that you can register such an EXE file to run once per user via ActiveSetup. You can also find another answer from me here.
Here is one more link to an explanation of ActiveSetup (I prefer the one above): http://www.ewall.org/tech/msi/self-healing
Also see these answer here: Stopping MSI from launching an EXE in the SYSTEM context

WiX : Windows Service fails to start as App.config is not yet modified

I have created a Windows Service Installer using WiX 3.8, everything works fine except that the service does not start upon installation, I have written a custom action which modifies the app.config with the user input values, the service fails to start because the app.config is not yet modified.
Is there a way I can schedule modifying App.config before the attempt to start the service is made?
Please help. Thanks in advance
Make your custom action run deferred and schedule it to run after InstallFiles and before StartServices, for example:
<CustomAction Id="SomeAction"
DllEntry="SomeEntry"
Return="ignore"
Execute="deferred"
BinaryKey="CA.dll"/>
<InstallExecuteSequence>
<Custom Action="SomeAction" After="InstallFiles"></Custom>
</InstallExecuteSequence>

Run .NET 2.0 console application in WiX custom action from binary table

I am trying to run a console application written in C# .NET 2.0 in a custom action in my WiX MSI setup project like this:
<CustomAction Id="INSTALL_TEXT" Impersonate="yes" Return="check" Execute="immediate" BinaryKey="TextCreator.exe" ExeCommand="C:\test.txt -i"/>
<CustomAction Id="UNINSTALL_TEXT" Impersonate="yes" Return="check" Execute="immediate" BinaryKey="TextCreator.exe" ExeCommand="C:\test.txt -u"/>
<Binary Id="TextCreator.exe" SourceFile="C:\MyInstaller\Test\Tools\TextCreator.exe"/>
<InstallExecuteSequence>
<Custom Action="INSTALL_TEXT" After="InstallFiles">NOT Installed AND NOT PATCH</Custom>
<Custom Action="UNINSTALL_TEXT" After="RemoveFiles">Installed AND REMOVE="ALL"</Custom>
</InstallExecuteSequence>
But I am always getting an error message in the log:
MSI (s) (7C:C0) [14:03:01:026]: Note: 1: 1721 2: INSTALL_TEXT 3: C:\Windows\Installer\MSI9938.tmp 4: C:\test.txt -i
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: INSTALL_TEXT, location: C:\Windows\Installer\MSI9938.tmp, command: C:\test.txt -i
MSI (s) (7C:C0) [14:03:07:374]: Product: Text Creator Console App -- 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: INSTALL_TEXT, location: C:\Windows\Installer\MSI9938.tmp, command: C:\test.txt -i
Action ended 14:03:07: INSTALL_TEXT. Return value 3.
I have embedded a MANIFEST in my application to run with administrative privileges:
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
When I run the installer from command line where the console prompt has already been started with administrative privileges, both install and uninstall work fine! But when I start the MSI using double-click I am asked to run the installation (before progress bar continues) if I want to run with administrative privileges. Then my setup aborts with the error message as provided in the LOG above.
What leads to that problem? I am using WiX 3.5.2519.0 with MSI 2.0 in my project. My setup is running on Windows 7 Professional (x64). I have all frameworks installed from 2.0, through 3.0, 3.5 up to 4.0!
EDIT: On Windows XP with .NET Framework 2.0 installed, all works just fine!
SOLUTION:
<CustomAction Id="QtExecInstallText" Impersonate="no" Return="check" Execute="deferred" BinaryKey="TextCreator.exe" ExeCommand="C:\test.txt -i"/>
<CustomAction Id="QtExecUninstallText" Impersonate="no" Return="check" Execute="deferred" BinaryKey="TextCreator.exe" ExeCommand="C:\test.txt -u"/>
<Binary Id="TextCreator.exe" SourceFile="C:\MyInstaller\Test\Tools\TextCreator.exe"/>
<InstallExecuteSequence>
<Custom Action="QtExecInstallText" After="InstallFiles">NOT Installed AND NOT PATCH</Custom>
<Custom Action="QtExecUninstallText" After="RemoveFiles">Installed AND REMOVE="ALL"</Custom>
</InstallExecuteSequence>
=> When linking pass -ext "%WIX%\bin\WixUtilExtension.dll" to light.exe!
The cleanest way to run any EXE in an MSI installer is using Quiet Execution Custom Action.
Examples of how to implement it are on the linked page. FWIW, a properly scheduled custom action (deferred with no impersonation) will already be running as system and manifest / UAC elevation won't apply. Additionally, if you can refactor your .NET EXE to be a client/server (EXE / DLL) arrangement then you can take the server class and consume it in a Deployment Tools Foundation (DTF) custom action.
This is a much better design as it runs in process rather than out of process and can call MSI APIs such as getting CustomActionData attributes, writing to the MSI log, returning ErrorSuccess and/or publishing progress bar updates and action messages. Forking to an EXE file is a hack compared to this.

Uninstall add-on setup when uninstall the Main setup using Wix

I am using wix in my installer,
I need to uninstall add-on Setup while uninstall the Main setup,
I am using the below code in Main setup wix,
<CustomAction Id="UNINSTALL_ADDON" Return="asyncNoWait" Execute="immediate" ExeCommand="msiexec.exe /x [add-onProductID] /qn” Property="add-onProductID" />
Below code in InstallExecute Table
<Custom Action="UNINSTALL_ADDON" Sequence="1282">(REMOVE="ALL")</Custom>
I am using the below property
<Property Id=" add-onProductID" Value="NULL" />
I have read the add-on Property Id from registry and pass it set to add-onProductID using CustomAction while uninstall the main setup.
This won’t help. Could you please help me to solve the issue?
You cannot install or uninstall another MSI during InstallExecuteSequence because Windows Installer doesn't support simultaneous install processes.
A solution is to make sure that your custom action is scheduled after InstallFinalize action (it's sequence is greater than InstallFinalize).