0

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.

Otherside
  • 2,805
  • 22
  • 21
VPDD
  • 131
  • 4
  • 7
  • 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 Aug 31 '10 at 12:57
  • See http://stackoverflow.com/questions/1576792/uninstall-fails-because-program-is-running-how-do-i-make-inno-setup-check-for-ru – ewall Aug 31 '10 at 13:10

3 Answers3

0

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))

Community
  • 1
  • 1
mishander
  • 139
  • 9
0

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);
LEo
  • 442
  • 5
  • 21
0

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.

demonplus
  • 5,613
  • 12
  • 49
  • 68
Sean B. Durkin
  • 12,659
  • 1
  • 36
  • 65