cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JoderCoder
Level 8

Closing the related applications pre-installation

I have a plug-in application and I need to close the applications like Outlook, Word, IE, etc before I start installing the applications. How can I do it in InstallShield means?
Labels (1)
0 Kudos
(9) Replies
lasiewicz
Level 6

You might try the following script

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

Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = " & strProcessKill )
For Each objProcess in colProcess
objProcess.Terminate()
Next
0 Kudos
JoderCoder
Level 8

Thanks, but I need to make a clarification: my installer needs to ask user to close the apps rather then killing the processes silently. FilesInUse dialog doesnt pick up my the applications I want.

Is there a way to explicitly pass the applications to FilesInUse dialog to show the applications needs to be closed?
0 Kudos
RobertDickau
Flexera Alumni

Searching the MSI help for "FilesInUse" and "InstallValidate" will turn up some leads. Please also see [thread=171533]this thread[/thread] on a similar question.
0 Kudos
JoderCoder
Level 8

RobertDickau wrote:
If you have the name of the EXE to shut down and its process ID, something like this before InstallValidate seems to work in VBScript:
Set myrec = Installer.CreateRecord(2)

myRec.StringData(1) = "SampleApp.exe"
myRec.IntegerData(2) = 4321
Session.Message &H05000000, myrec ' msiMessageTypeFilesInUse, that is

It doesn't seem to respect the Exit button, but perhaps it's a start...


Thanks Robert, I am doing everything in a C++ dll. And I got to the same point that you advised above and observed the same that the buttons (retry and exit) are not respected. Any further suggestions how to get around this?

On another note, if there is no window for the process, it gives this error "Window could not be found. Process ID: 4300". So could you think of something that could cover the processes with no windows as well?

Thanks very much!
0 Kudos
JoderCoder
Level 8

On thing I noticed on this is that once I send the FilesInUse message;

MsiProcessMessage(ghMsi, INSTALLMESSAGE(INSTALLMESSAGE_FILESINUSE), hRecord);


custom action doesnt execute the next line until I hit a button on the FilesInUse dialog. Why custom action is hanging there? I want the custom action to continue executing later lines after the line above. Could you suggest how I can do that?

Also, in order to get the Retry and Exit buttons respected, I am planning to put Actions for them as well.

Thanks much!
0 Kudos
JoderCoder
Level 8

Another note, the only log printed after I call MsiProcessMessage function is this:

MSI (c) (40:E4) [08:43:18:128]: Note: 1: 2262 2: ListBox 3: -2147287038

and everything stops there, until I hit some buttom on the dialog.
0 Kudos
RobertDickau
Flexera Alumni

The pause is presumably MsiProcessMessage waiting for a button click so it can return the constant (IDRETRY, IDIGNORE, IDCANCEL?) indicating the button the user clicked.

Regarding windowless processes, that behavior is documented in the MSI topic "Sending Messages to Windows Installer Using MsiProcessMessage", the idea being that the user wouldn't generally know how to shut down a windowless process.
0 Kudos
JoderCoder
Level 8

Excellent! Thanks much, Robert!

One (hopefully) last question on this, so if MsiProcessMessage returns IDCANCEL, how can I tell the msi to exit the installation gracefully?
0 Kudos
RobertDickau
Flexera Alumni

The typical way is for your custom action function to return ERROR_INSTALL_FAILURE.
0 Kudos