0
votes

I need some help with inno setup. If it is possible, I would like to know how to:

Check if a process appears during the time an .exe file is running (the .exe is called from inno installation) and if the process appears kill it.

Thanks a lot in advance.

3
Inno-setup doesn't really have much to do with your question. It doesn't matter if the monitoring program is started from inno-setup or some other way.Otherside

3 Answers

0
votes

Close running process you can find here: https://stackoverflow.com/a/24014649/2952483 Then just do it on timer (TTimer if you use chinease extended version of inno setup, or callback functions if you use standart (like here Inno setup: Display Images using timer))

0
votes

you can execute a cmd with Exec() in inno setup, and check ResultCode value.eg:

Exec(ExpandConstant('{cmd}'), '/C tasklist | findstr "test.exe"', '',         SW_SHOWNORMAL,ewWaitUntilTerminated, ResultCode);

if ResultCode is not 0,execute a cmd again will kill the test.exe process.

Exec(ExpandConstant('{cmd}'), '/C taskkill /IM test.exe', '',         SW_SHOWNORMAL,ewWaitUntilTerminated, ResultCode);
0
votes

Make a DLL and link to it from your script. In the DLL, use the windows API to accomplish what you need. For example:

GenerateConsoleCtrlEvent( CTRL_C_EVENT, dwProcessId)

will send a control-C to a console application. OR:

TerminateProcess( ProcessHandle, 1);

will terminate the referenced process. Check MSDN for details.