Run exe before installing files - not working on Vista - 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!

jafa
Posts: 51
Joined: Fri Feb 23, 2007 7:13 pm

Run exe before installing files - not working on Vista

Hi,

We need the installer to stop a number of services (not installed by our installer) and to close our applications (for example a utility that sits on the notification bar).

To do this I have a small exe that detects and stops/closes the necessary services/applications. The exe has a manifest that requests Admin rights and works when run manually under both XP and Vista.

I have configured AI to execute this exe under "InstallExecuteSequence", "Begin".

This works as expected under XP but the exe is not executed under Vista.

If I move it to the "Install" section I can set it for "Deferred with no impersonation". This causes it to be run under Vista but it is too late in the process - we need it to be run before AI checks for in-use files.

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

Hi,

If this EXE must be run elevated, it must be set as "Deferred with no impersonation". The earliest stage under which you can schedule a deferred custom action is "InstallInitialize", which comes after Windows Installer (not AI) performs the Files in Use check (on "InstallValidate"). Therefore, you cannot use this custom action in a MSI file.

The workaround is to use a bootstrapper for the MSI file which will require administrator privileges. The elevated bootstrapper will also elevate the MSI and the custom action, allowing it to run as Immediate (like on XP).

In order to set the bootstrapper to require administrator privileges you can use the "Require Administrator" option in the "Bootstrapper" tab of the "Media" page.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
jafa
Posts: 51
Joined: Fri Feb 23, 2007 7:13 pm

Worked perfectly - thanks!
bhodso
Posts: 19
Joined: Sun Apr 20, 2008 1:11 am

Re: Run exe before installing files - not working on Vista

I designed my exe's to look for a "kill" file when they are running. If the file is ever written, the shut themselves down. They are running in the system tray so of course, each time the user tries to uninstall on Windows Vista, they get this annoying prompt saying that certain files are in use and must be closed before continuing. My custom action runs immediately after they respond to this prompt and gracefully shuts down these apps so the installer can remove everything, etc.

Is there a way I could use a custom action that could run BEFORE the MSI checks for files in use that would write this kill file? What could I use for that?
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Run exe before installing files - not working on Vista

Hi,

Like I said in one of the previous posts, this can be done by using an EXE bootstrapper for the installation package. This EXE bootstrapper will require Administrator privileges and it will allow a custom action to run on Vista before the "InstallInitialize" standard action. This custom action can write to the file you want before Windows Installer performs the "Files in use" check.
What could I use for that?
In order to write into a text file you can use any custom action you want. For example, you can use the OpenTextFile method.

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

Return to “Common Problems”