This should be simple, I need to stop any previous version of my program from running when the installer starts.
Most people suggested making an exe
which does this and calling it before Inno Setup starts. I created an exe
using AutoIt which kills all processes of my program. The problem is I don't know how to get Inno Setup to call it before it installs anything.
How do I call an executable before installing files?
Alternatively, if I can just detect if a program is running and tell the user to close it, that would work too.
If you are happy to write your own DLL, you can use the tool help API for TlHelp32.pas to determine what applications are running, and then get a window handle for them using EnumWindows, then send a WM_CLOSE to the window handle.
It's a bit of a pain, but it should work: I have some utility wrapper classes I developed with a friend a while back. Can't remember if we based it on someone else's code.
TWindows.ProcessISRunning and TWindows.StopProcess may help.
I have had success using WMIC :
You can also do it in the
InitializeSetup
but if you do, keep in mind you don't have yet access to the{app}
constant. My program doesn't ask for install path, but yours might.Here's a link to an Inno Setup script that prompts a user to close the target program, if it detects that the program is running. After the user closes the program, they can click on a "Retry" button to proceed with the installation:
http://www.domador.net/extras/code-samples/inno-setup-close-a-program-before-reinstalling-it/
This script is based on a simpler script, found in the Inno Setup Extensions Knowledge Base:
http://www.vincenzo.net/isxkb/index.php?title=Call_psvince.dll_on_install_and_uninstall