Pepa
Posts: 15
Joined: Fri Jul 07, 2006 7:59 pm
Location: USA
Contact: Website

Conditional install if process is running

I need to abort installation, with custom message, if certain process is running.

I can not kill that process, I can only prompt user to exit it and try installation again.

Is there some easy way to do this? I tried custom action which kills the msiexec process if the running process is detected, but it doesn't quite work. There must be a better way...

Unfortunatelly, prerequisites do not seem to check for return value, or do they?

Thank you for your help.
ssearles
Posts: 65
Joined: Tue Oct 30, 2007 12:54 pm

um, maybe I'm missing something... but why would you want to kill the process your using for your installer?


Plus, doesn't msiexec already restrict you to only one installation instance at a time actually running?
Pepa
Posts: 15
Joined: Fri Jul 07, 2006 7:59 pm
Location: USA
Contact: Website

Maybe I didn't make it clear enough.

Part of my installation is DLL that program A may or may not be accessing at the time the installation is initiated (it is separate application). If it was being accessed then the installation would not install the dll (can't overwrite dll that is currently running).

For various reasons, I can not simply shut the process A down. I need to display a message informing user that the installation can not proceed unless he shuts that program A down - and then abort the current installation.

Or something like that - I need some idea on how to do this...
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Hi,

This can be done by using an additional launch condition. Here are the steps:
- create a VBScript custom action which contains this code:

Code: Select all

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

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

For Each objProcess in colProcess
if objProcess.Name = "AdvancedInstaller.exe" then
	Session.Property("PROCESS")="RUNNING"
End If
Next
- this is set for verifying if the "AdvancedInstaller.exe" process is running, therefore you need to modify it to find your process (replace "AdvancedInstaller.exe" in the code)
- in the "Custom Actions" page add this custom action as an Attached custom action under the "InstallUISequence" -> "FindRelatedProducts" standard action (just before the "LaunchConditions" standard action)
- you can see a standard action by using the "Show Standard Action" button on the toolbar
- make sure that in the "Custom Action Properties" page the "Function Name" field is empty (the rest of the settings are the default ones)
- since the PROCESS property needs to be initialized before searching the process, you go to "Install Parameters" page and create the PROCESS property with the value NOT RUNNING
- finally, go to the "Prerequisites" page and create this additional launch condition:

Code: Select all

PROCESS="NOT RUNNING"        Advanced Installer is running, please close it                                     before running the installation.
Let me know if you encounter any problems.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Pepa
Posts: 15
Joined: Fri Jul 07, 2006 7:59 pm
Location: USA
Contact: Website

Thank you Cosmin.
Cool!

Return to “Common Problems”