Detecting Process And Halting Installation - 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!

Cash
Posts: 18
Joined: Thu Aug 28, 2008 9:34 pm

Detecting Process And Halting Installation

I've read the forum and think I am pretty close to getting this figured out. First, here is what I want to do:

As soon as the installer is started, I want to see if a program is already running. If it is, I want to display a message to the user and exit the installation.

I have the VB Script set so that it checks to see if the process is running. I followed the instructions here (and used the VB script): http://www.advancedinstaller.com/user-g ... ocess.html

I also created a new Custom Launch Condition as: PROCESS = "RUNNING"

If the process does not equal RUNNING, it should present the dialog and exit. My problem is that no matter if the process is running or not, it ALWAYS shows the message and stops the installation. I am using Vista on my development machine and this is the only machine I have tried so far. Also, I am testing this from the IDE and not running the installer file direclty. This should still work, right?

What am I doing wrong?

-Scott
Cash
Posts: 18
Joined: Thu Aug 28, 2008 9:34 pm

Re: Detecting Process And Halting Installation

Also, I have created a Custom Action (under FindRelatedProducts) and added my VB scirpt to the action (leaving Funciton name empty and everything else default).

Any help is greatly appriciated.

-Scott
gigi
Posts: 2103
Joined: Tue Apr 11, 2006 9:55 am
Contact: Website

Re: Detecting Process And Halting Installation

Hi Scott,
As soon as the installer is started, I want to see if a program is already running. If it is, I want to display a message to the user and exit the installation.
Note that this is managed automatically by Windows Installer. If the application that is upgraded is currently running then the "FilesInUse" dialog is displayed telling the user which application is in use and to stop that application:
http://msdn.microsoft.com/en-us/library/aa368592.aspx

Also if you want to restart your application during upgrade (avoid a system reboot) you can use on Windows Vista the Restart Manager Windows Installer 4.0 feature. Read more about this here:
http://www.advancedinstaller.com/user-g ... nager.html
http://msdn.microsoft.com/en-us/library ... S.85).aspx

However why exactly you want to manage this manually with a custom action ?

Regards,
Gigi
Gheorghe Rada
Advanced Installer Team
http://www.advancedinstaller.com/
Cash
Posts: 18
Joined: Thu Aug 28, 2008 9:34 pm

Re: Detecting Process And Halting Installation

My installation is a plug in of a much larger application. It adds/changes files that may or may not be in use. I need to make sure the application is shut down so the installer does not try to modify XML files the same time the application tries to access it. I have many reasons for needing to be certain the application is not running. The FilesInUse dialog will not work since it may not be in use when the installation starts, but the application may try to access one of the files I am modifying after it has started.

I just want to know how to detect a running process and not let the installation continue until it is shut down. This seems like a pretty simple request, but by the looks of other messages on this board, maybe it's not.

I'm a paid customer. Is there another support area I should be asking this question in?

Thanks,

-Scott
Ionut
Posts: 605
Joined: Tue Nov 22, 2005 11:29 am
Contact: Website

Re: Detecting Process And Halting Installation

Hi Scott,
I also created a new Custom Launch Condition as: PROCESS = "RUNNING"
The condition should actually be:

Code: Select all

PROCESS = "NOT RUNNING"
because the installation should be allowed only when the program is not running. A Launch Condition must be true in order for the installation to continue; if a Launch Condition evaluates to false, the corresponding error text is displayed.

For debugging purposes, you can insert a line such as the following at the end of your VBScript (in order to display the value of the PROCESS Property):

Code: Select all

MsgBox Session.Property("PROCESS")
If you still encounter problems, please send the AIP file and the VBS script you are using (in case you have performed any significant modifications to the one provided as example) to support at advancedinstaller dot com in order to investigate the issue.
I'm a paid customer. Is there another support area I should be asking this question in?
You can post any questions regarding AI in this forum or you can send an email to our support address mentioned above - it all depends on your preferences.

Regards,
Ionut
Denis Toma
Advanced Installer Team
http://www.advancedinstaller.com/
Cash
Posts: 18
Joined: Thu Aug 28, 2008 9:34 pm

Re: Detecting Process And Halting Installation

Can I get some help with this issue? I've spelled out what I am trying to do and what I have done to date. How do I get this resolved.

Thanks,

-Scott
Cash
Posts: 18
Joined: Thu Aug 28, 2008 9:34 pm

Re: Detecting Process And Halting Installation

Sorry, we posted at the same time. Reading your post now.

Thanks,

-Scott
Cash
Posts: 18
Joined: Thu Aug 28, 2008 9:34 pm

Re: Detecting Process And Halting Installation

I've tried it both ways. I also added the message box to the VB script, but it shows the same value regardless if the application in question is really running or not.

Does this have something to do with the fact that I am on Vista?

-Scott
Cash
Posts: 18
Joined: Thu Aug 28, 2008 9:34 pm

Re: Detecting Process And Halting Installation

After a little more testing, I don't belive the VBScript is running correctly. The message box is never being displayed. Here is what I am using:

Dim objWMIService, objProcess, colProcess
Dim strComputer
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colProcess = objWMIService.ExecQuery ("Select * from Win32_Process")

Session.Property("PROCESS")="NOT RUNNING"
For Each objProcess in colProcess
if objProcess.Name = "MyApplication.exe" then
Session.Property("PROCESS")="RUNNING"
End If
MsgBox Session.Property("PROCESS")
Next
Cash
Posts: 18
Joined: Thu Aug 28, 2008 9:34 pm

Re: Detecting Process And Halting Installation

I just sent my aip file to the support address.

-Scott
Ionut
Posts: 605
Joined: Tue Nov 22, 2005 11:29 am
Contact: Website

Re: Detecting Process And Halting Installation

Hi Scott,

1. Note that Launch Conditions are evaluated in both sequences (InstallUI and InstallExecute). Because your Custom Action is scheduled in the InstallExecute sequence, it is never executed and the Launch Condition will always fail (since the initial value of the PROCESS Property is empty which does not equal "RUNNING" or "NOT RUNNING"). The correct method is to add the CA twice in both sequence tables (hold SHIFT and drag-and-drop the CA in the tree control under "InstallUISequence -> FindRelatedProducts"). Additionally, select the option "Execute only once if present in both sequence tables".

2. The message box is never displayed because the CA is never executed (for the reason mentioned above). Additionally, move the MsgBox statement at the end of the script, after "Next", otherwise it will be displayed for each running process.

3. Use the condition I have mentioned previously after performing the changes from point 1. The online help will also be corrected.

Let me know if this solves the problem.

Regards,
Ionut
Denis Toma
Advanced Installer Team
http://www.advancedinstaller.com/
Cash
Posts: 18
Joined: Thu Aug 28, 2008 9:34 pm

Re: Detecting Process And Halting Installation

Ionut,

This fixed the problem. After adding the FindRelatedProducts (standard action) to InstallUISequence and copying my script into that location, everything worked great. As you suggested, the Custom Action needs to be in both locations.

Thanks!

-Scott

Return to “Common Problems”