开发者

Inno setup, check for process during a .exe is running and kill it

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 f开发者_JAVA百科ile is running (the .exe is called from inno installation) and if the process appears kill it.

Thanks a lot in advance.


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


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜