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

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.

Related

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.

immediately calling custom action when uninstalling program

I've a question aboud a custom action that needs to take place during an uninstall. currently I have the custom action working for the biggest part, however there is a small problem.
The custom action needs to take place immediately after the uninstall option is selected since it contains the command to force the running program( installed with the same installer) to close and some other commands for other tasks. bud currently the WIX installer tries to close the program by itself which it is unable to. that means my custom action as well as the rest of the uninstall will fail.
currently I have this code bud it is not working at the point I would like it to.
<CustomAction
Id="UninstallScript"
Directory="INSTALLFOLDER"
ExeCommand="[INSTALLFOLDER]De-installation script.exe"
Execute="commit"
Return="check">
</CustomAction>
<InstallExecuteSequence>
<Custom Action="UninstallScript" Before="InstallInitialize"> Installed AND NOT UPGRADINGPRODUCTCODE AND NOT REINSTALL </Custom>
</InstallExecuteSequence>
any idea how I can make it work the way I intended?
note: if I manually close the running program and then run the uninstall option it works fine. which means the timing of my function needs to be moved forward. also the running program starts when Windows boots up which means it won't show the desktop bud directly shows the program ( this is intentionally ).
thanks in advance,

Install program fails to shutdown running target...workarounds?

I have a WIX install program.
When I test my install program on a machine where the old version of the software is running, I get the prompt below.
The problem is that the installer can't manage to close the application. When the new program runs, it complains about the old one running.
Is there a way to forcefully kill the app?
If not, is there some entry in WIX that will require the user to shutdown the application before it will continue installation?
I found the answer here:
WiX <util:CloseApplication> element not working
I made one tweak to the solution in the post above. I kill the application earlier in the install sequence so the window above doesn't appear.
<!-- Code to force termination of running program...MSIExec couldn't do it -->
<Property Id="QtExecCmdLine" Value='"[WindowsFolder]\System32\taskkill.exe" /F /IM "$(var.ProductName).exe"'/>
<CustomAction Id="APP.TaskClose" BinaryKey="WixCA" DllEntry="CAQuietExec" Execute="immediate" Return="ignore"/>
<InstallExecuteSequence>
<Custom Action="APP.TaskClose" After="LaunchConditions"/>
</InstallExecuteSequence>
If you are wondering what "$(var.ProductName).exe" is, I pass the exe name on the commandline because I'm creating several branded versions of the same program. Just substitute your exe name.
And yes, it is safe in this particular intance to do this. There is no data held in memory that could be lost.
You should use the WiX util extension CloseApplication:
http://wixtoolset.org/documentation/manual/v3/xsd/util/closeapplication.html
That should work.
Long term you should get the app integrated with Restart Manager so it will shut down automatically.

WIX MSI customaction not running when deployed using Group Policy

I'm using WIX to create an MSI which has a custom action to install a clickonce application. I want to deploy the MSI via GPO. The custom action runs fine when I just double click to run the msi, but the custom action does not seems to be running when deployed via GPO. But if you look at the add/remove programs in the control panel you have the product/msi listed there as if it was successfully installed.
To see if custom actions work at all when deploying via GPO I created a simple custom action which just writes a file to c:\temp (existing) folder. Added the custom action to both InstallExecuteSequence and AdminExecuteSequence in before installfinalize step. Tried both deffered execute and immediate execute. It works when you double click the msi to install but not via GPO.
Is it possible to have custom actions when the msi is deployed through GPO? Are there any limitations? Is there anything special that I need to do to get it to work with GPO?
Thanks in advance!
Rukshan
I figured it out. The issue was that I hadn't configured the GPO to install the package when the user logs in. After checking that check box in the group policy properties it works.
If you assign the software to users and do not check "install this application at logon", the application will be listed on the user's add/remove programs panel but doesn't really install it. So I was under the impression that it was successfully installed without running the custom action when it really wasn't installed.
Now I have my custom action listed under Install Execute sequence
<InstallExecuteSequence>
<Custom Before='InstallFinalize' Action='ClickOnceIntallCustomAction' >NOT REMOVE</Custom>
</InstallExecuteSequence>
And it is set to execute immediately and check on return
<CustomAction Id="ClickOnceIntallCustomAction" BinaryKey="ClickOnceInstallBinary" Return="check" Execute="immediate" DllEntry="Test" ></CustomAction>

How to execute Wix custom action after installation?

I am using Wix3 to install WCF service to IIS.
How can I use my custom action (c#) function after installation completed? i.e. I need to open installed web.config file and replace hostname with real one.
Any ideas?
You can schedule it after InstallFinalize action in InstallExecuteSequence.
There is a sequence of Actions in Windows Installer. The WiX tutorial has a good section on events (and is a great resource anyway).
A typical example of getting something to run after InstallFinalize is to get the installed app to start.
<InstallExecuteSequence>
<Custom Action='LaunchFile' After='InstallFinalize'>NOT Installed</Custom>
</InstallExecuteSequence>
Why would you:
1) Need a custom action?
2) Do it after the install instead of during the install?
WiX has a built-in extension for handling what you are trying to do:
XmlFile Element (Util Extension)
It will update your XML after the file has been installed and handle rollback scenarios as well.
What you will have to write a CA for though is reading the XML value back into a property ti handle repair and upgrade situations. Read:
The WiX toolset's "Remember Property" pattern.