cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Pilgrim

Does Kill-Process Custom Action actually work?

I've created a Kill-Process Custom Action per the instructions provided in the Help file. I'm using the KillProcessDeferred function, I created a New Property which matches the name of the Custom Action, and added the name of the process that I want to kill. I inserted the Custom Action in the Installation Execute sequence between the "InstallInitialize" and the "InstallFinalize" sequences. I "think" I've done everything correctly. Yet it doesn't work.

Instead I'm prompted by the InstallShield default screen which displays the running process, and gives me the two radio-button choices to kill the processes now or later.

I want the processes to be killed without the user having to intervene.

So I see in the discussion threads that the InstallSite.org has samples to use for doing this (List and Shut Down Running Applications.) Apparently this method does work, but the InstallShield doesn't?

Has anyone had any success with using the CA, and if so, what else is missing from the instructions?

Thanks!
Labels (1)
0 Kudos
2 Replies
Highlighted
Pilgrim

Re: Does Kill-Process Custom Action actually work?

I just tested this and it worked ok for me. InstallShield 2012 Spring, Windows 7. Here are the steps I took:

1. Create a new basic MSI project.
2. Add a file.
3. Add a "New Kill Process" custom action.
4. name the custom action: KillThis
5. Set the "In-Script Execution" to: Deferred Execution
6. Set the "Install Exec Sequence" to: After InstallInitialize
7. Create a new propery named: KillThis
8. set the property name to: notepad.exe
Note the process name must appear exactly as it does in Windows Task Manager. "Notepad" would not work here.
9. Launch notepad.
10. Build and run the setup. notepad.exe silently terminates.

I tried an alternate method of killing a process and this worked as well:
1. Create a new basic MSI project.
2. Add a file.
3. Add a "New Exe | path referencing a directory" custom action.
4. Set "Working Directory" to: SystemFolder
5. Set "File Name & Command Line to: taskkill.exe /f /im notepad.exe
6. Set "In-Script Execution" to Deferred Execution
7. Set the "Install Exec Sequence" to: After InstallInitialize
8. Launch notepad.
9. Build and run the setup. notepad.exe silently terminates.
0 Kudos
Highlighted
Pilgrim

Re: Does Kill-Process Custom Action actually work?

Slowly learning here ….

I tried both of your suggestions, which work fine as long as notepad.exe is what I’m trying to kill.

But as it turns out, the process I’m trying to kill is one of the files I’m trying to install (which wasn't made clear in my original post). That is, the when I uninstall this product I want to first check to make sure the process isn’t running, and kill the process if it is.

What seems to be happening is that the Files In Use dialog and function are being called by the installer before my Custom Action is being called, so I end up seeing the Files In Use dialog pop up anyway.

I’m not sure where in the sequence of things that the Files In Use check is being called. But I tried something a little different to work around the issue.

Since this is an InstallScript MSI project, I can get to the Dialog Source in the InstallScript section under Behavior and Logic. By commenting out the While Loop, I effectively removed the loop that waits for the user to click a button, and forced the OK button to be “pressed” in the code, so the dialog exits about as soon as it’s opened, with the default values selected. The Files In Use dialog closes almost immediately and the process (the one I’m uninstalling) is killed. Works like a charm.
0 Kudos