Custom action to close running process during uninstall - Advanced Installer Community

We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

peter813
Posts: 2
Joined: Wed Apr 16, 2008 6:13 pm

Custom action to close running process during uninstall

Hi all,

I've got a msi which runs fine on XP, which has a custom action in CostInitialize which starts an attached executable (during uninstall) which detects the process of our application being uninstalled, and sends our process a WM_CLOSE to close gracefully. Works fine on XP, but does not work on Vista. The msi log shows a 1721 error saying that it cannot run the custom action, which is set to ignore exit code, so the installation does not fail, but then the Installer shows the FilesInUse dialog, which is not what I want. This happens also when User Account Control is disabled.

I found one other post which comes very close to what I'm trying to accomplish:
http://www.advancedinstaller.com/forums ... ess#p13043

But the solution given there (build a bootstrap installation executable, with a manifest so that it runs elevated) does not work for me. I need my installation to be an msi, not an exe.

The closest I've come to a solution is to make a custom action (in CostInitialize) which runs a vbs script which uses WMI to loop through the processes and terminates our process. This works, the downside is that is kills the process, does not let it close gracefully, and therefore it leaves our icon in the system tray (our process shows an icon in the system tray, which Windows does not remove when the process dies, it only does this when you "hover" over the icon after the process has been killed).

Is there any other way to accomplish this in a way that it works both on XP and Vista (with or without User Account Control)?

Thanks in advance,

Peter
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Custom action to close running process during uninstall

Hi,

You are encountering this behavior because the custom action used by the package must be set as "Deferred with no impersonation" when running on Windows Vista. Therefore, I'm afraid that what you need cannot be done (the installation will show the "FilesInUse" dialog).

This is because a deferred custom action can be scheduled only after "InstallInitialize" and the check for the "FilesInUse" dialog is performed during "InstallValidate" (which is before "InstallInitialize").

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
peter813
Posts: 2
Joined: Wed Apr 16, 2008 6:13 pm

Re: Custom action to close running process during uninstall

Hi cosmin,

Thanks for your quick reply!

Does that mean there is no way that I can close the running process during uninstall without showing the FilesInUse dialog? (at least not on Vista)
Our application is a background app, so it's not like the user "forgot" to close the app (in which case the dialog would make sense), but the executable is always running (launched from the HKLM\...\Run key). What surprised me is the difference in behaviour on XP and Vista (with UAC DISABLED); is this caused by a difference in Installer version on XP/Vista?

Thanks,
Peter
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Custom action to close running process during uninstall

Hi,
Does that mean there is no way that I can close the running process during uninstall without showing the FilesInUse dialog?
The only solution I can think of is to use a bootstrapper which requires Administrator privileges. This can be done by setting the execution level in the Bootstrapper tab of the "Media" page.

However, if this is not an option for you then there is no solution.
is this caused by a difference in Installer version on XP/Vista?
No, this is caused by the way the Windows Vista operating system works. Basically, it doesn't matter if the UAC is on or off, it matters only the credentials offered by the user during the installation process. Therefore, a bootstrapper which requires Administrator privileges gives the installation enough credentials to execute an Immediate custom action which stops a process.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”