Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8050753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:09:03+00:00 2026-06-05T07:09:03+00:00

In my Inno Setup script I am executing 3rd party executable. I am using

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T07:09:03+00:00Added an answer on June 5, 2026 at 7:09 am

    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 the TerminateProcess function, where the 666 value is the process exit code (quite evil in this case 🙂

    [Code]
    #IFDEF UNICODE
      #DEFINE AW "W"
    #ELSE
      #DEFINE AW "A"
    #ENDIF
    
    const
      WAIT_TIMEOUT = $00000102;
      SEE_MASK_NOCLOSEPROCESS = $00000040;
    
    type
      TShellExecuteInfo = record
        cbSize: DWORD;
        fMask: Cardinal;
        Wnd: HWND;
        lpVerb: string;
        lpFile: string;
        lpParameters: string;
        lpDirectory: string;
        nShow: Integer;
        hInstApp: THandle;    
        lpIDList: DWORD;
        lpClass: string;
        hkeyClass: THandle;
        dwHotKey: DWORD;
        hMonitor: THandle;
        hProcess: THandle;
      end;
    
    function ShellExecuteEx(var lpExecInfo: TShellExecuteInfo): BOOL; 
      external 'ShellExecuteEx{#AW}@shell32.dll stdcall';
    function WaitForSingleObject(hHandle: THandle; dwMilliseconds: DWORD): DWORD; 
      external 'WaitForSingleObject@kernel32.dll stdcall';
    function TerminateProcess(hProcess: THandle; uExitCode: UINT): BOOL;
      external 'TerminateProcess@kernel32.dll stdcall';
    
    function NextButtonClick(CurPageID: Integer): Boolean;
    var
      ExecInfo: TShellExecuteInfo;
    begin
      Result := True;
    
      if CurPageID = wpWelcome then
      begin
        ExecInfo.cbSize := SizeOf(ExecInfo);
        ExecInfo.fMask := SEE_MASK_NOCLOSEPROCESS;
        ExecInfo.Wnd := 0;
        ExecInfo.lpFile := 'calc.exe';
        ExecInfo.nShow := SW_HIDE;
    
        if ShellExecuteEx(ExecInfo) then
        begin
          if WaitForSingleObject(ExecInfo.hProcess, 3000) = WAIT_TIMEOUT then
          begin
            TerminateProcess(ExecInfo.hProcess, 666);
            MsgBox('You just killed a little kitty!', mbError, MB_OK);
          end
          else
            MsgBox('The process was terminated in time!', mbInformation, MB_OK);
        end;
      end;
    end;
    

    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)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My Inno Setup script includes a directory: [Files] ... Source: C:\MyProg\Tools\*.*; Destdir: {app}\Tools ...
I'm using an Inno Setup script to install my 32- and 64-bit DLLs in
I currently have this in this part of Inno script [Run] Filename: {app}\bin\vcredist_x86.exe; Parameters:
I have a simple inno-setup script that allows my setup to install either the
I am using Inno Setup to make an installer for a project I am
I need an Inno Setup script that copies a folder recursively.
I have an Inno Setup script with preprocessor directives ( #define s, #if s,
I have some commands in the [Run] section of my Inno Setup script. Right
When compiling an Inno Setup installer script I get this error Line: xx Resource
I'm writing a Inno Setup script which need to execute a very old third

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.