How to stop application automatically before running of uninstallation procedure? - wix

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.

Related

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

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" />

WIX custom action error

I need to execute one DLL during installation of MSI package . The DLL will create a DSN. I added a custom action for that.
<Binary Id="CustomActionBinary" SourceFile="C:\MemDbDrv_3010.dll"/>
<CustomAction Id="CustomActionId" BinaryKey="CustomActionBinary" DllEntry="SelfInstall" Execute="immediate" Return="check" />
<InstallExecuteSequence>
<Custom Action="CustomActionId" Before='InstallFinalize'/>
</InstallExecuteSequence>
It is compiling fine. But while installing the package I am getting the below error
"There is a problem with this Windows installer package.A DLL required for this install to complete could not be run. Contact your support personnel or package vendor"
Can you please help what could be the resolution
Your custom action crashed or didn't load, so you may need to say what language it is and worry about missing dependencies, or even show the code if you don't get anywhere with this. However:
Immediate custom actions run before anything is installed, so if it has any dependent Dlls then they won't yet be installed.
Immediate custom actions shouldn't alter the system because they can't be undone in the event of the install failing. It should be deferred with a rollback to undo it.
It's won't run elevated as immediate, so if it needs privilege to work then it will fail. Deferred CAs run elevated with the system account if they are impersonation=no, so that may be what you need.

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 installer: The application is launched in SYSTEM user

I have an installer in WIX. I have tried to deploy it to a group of target computers in the network and encountered the following issue. The deployment was successful but there is an issue when the installer launches the application after the installation finishes using the following code:
<CustomAction Id="RunMainApp" Directory="SUBDIR" ExeCommand="[SUBDIR]clicksharelauncher.exe" Execute="deferred" Return="asyncNoWait"/>
<InstallExecuteSequence>
<Custom Action="RunMainApp" Before="InstallFinalize"><![CDATA[UILevel=5 OR LAUNCH_APP~="YES" AND NOT Installed]]></Custom>
</InstallExecuteSequence>
When the application is launched, I realized that it is launched in SYSTEM user. Therefore, I get an error from the application saying that the application can't run in SYSTEM user. Could anyone tell me if there is a way to fix it?
This is happening because the InstallExecute phase of the installation runs as the SYSTEM account, and you're launching the application during that phase.
You'll need to get the custom action to Impersonate the user executing the installation by adding Impersonate="yes" to the custom action element.
More details can be found under the Impersonate section here:
http://wixtoolset.org/documentation/manual/v3/xsd/wix/customaction.html
The following link provides details on how to add the startup of an application in the UI:
http://wixtoolset.org/documentation/manual/v3/howtos/ui_and_localization/run_program_after_install.html

How to get rid of the "files in use" dialog during uninstall?

I'm very new to WIX and am using the minimal GUI to install and uninstall a dll. This dll gets registered as a service in a custom install script that I am calling upon install.
Upon uninstall, I stop and unregister the service in a custom script.
My problem is, before the custom uninstall script is called, I get the files in use dialog box as the dll is being used by the service. I want to avoid this, as I know I will be stopping the service in the custom uninstall action.
Any easy solutions to this problem ?
Thanks!
Nikhil.
Are you using a Custom Action to stop the service? If so I'd make sure that your custom action is run before the removal of your file
i.e.
<CustomAction Id="StopService" Directory="DirMyService" ExeCommand="NET STOP ServiceName" />
<CustomAction Id="StartService" Directory="DirMyService" ExeCommand="NET START ServiceName" />
<InstallExecuteSequence>
<Custom Action="StopService" After="InstallInitialize">Installed</Custom>
<Custom Action="StartService" Before="InstallFinalize">Installed</Custom>
</InstallExecuteSequence>
Haven't tested this, so you may need to stick in the windir before the net stop etc, and those might be the wrong places to put it in to stop/start the scripts. But might give you an idea of how to solve your problem.