I install a service/daemon, which needs to be killed before uninstall and reinstall.
I already found out how to do it for uninstall:
[UninstallRun]
Filename: "taskkill"; Parameters: "/im ""My Service.exe"" /f"; Flags: runhidden
The [Run]
section, however, runs after install, so I can't use it for that. What is the best way to kill the process using taskkill
before install?
Please note that I specifically want to kill the process. A more complex solution using IPC offers no benefits in my case, I just want to execute taskkill
before installing a particular file.
Unless the installer is running on a Windows XP machine, or you have set
CloseApplications
directive tono
(the default isyes
), the installer should close the application automatically:The functionality is available since Inno Setup 5.5 on Windows Vista and newer.
I found a way using the
BeforeInstall
keyword and a simple Pascal function in the code section. I added a string parameter so it can be reused for multiple processes.