In my Inno Setup script I am executing 3rd party executable. I am using the Exec()
function as below:
Exec(ExpandConstant('{app}\SomeExe.exe'), '', '', SW_HIDE, ewWaitUntilTerminated, ErrorCode);
By mentioning ewWaitUntilTerminated
it waits until the SomeExe.exe
doesn't quit. I want to wait only for 10 secs.
Is there any solution for that?
Assuming you want to execute external application, waiting for its termination for a specified time and if it's not terminated by itself killing it from setup try the following code. To the magical constants used here, 3000 used as the parameter in the
WaitForSingleObject
function is the time in milliseconds for how long the setup will wait for the process to terminate. If it doesn't terminate in that time by itself, it is killed by theTerminateProcess
function, where the 666 value is the process exit code (quite evil in this case :-)The code I've tested with Inno Setup 5.4.3 Unicode and ANSI version on Windows 7 (thanks to kobik for his idea to use conditional defines for Windows API function declarations from
this post
)