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 662629
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:23:59+00:00 2026-05-13T23:23:59+00:00

I have bat-file, that make some operations. How to run this file from Delphi

  • 0

I have bat-file, that make some operations. How to run this file from Delphi and wait, until it stops.
Something like that:

procedure TForm1.Button1Click(Sender: TObject);
begin
//Starting bat-file
bla-bla-bla
showmessage('Done');
end;
  • 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-05-13T23:23:59+00:00Added an answer on May 13, 2026 at 11:23 pm

    This executes the given command line and waits for the program started by the command line to exit. Returns true if the program returns a zero exit code and false if the program doesn’t start or returns a non-zero error code.

    function ExecAndWait(const CommandLine: string) : Boolean;
    var
      StartupInfo: Windows.TStartupInfo;        // start-up info passed to process
      ProcessInfo: Windows.TProcessInformation; // info about the process
      ProcessExitCode: Windows.DWord;           // process's exit code
    begin
      // Set default error result
      Result := False;
      // Initialise startup info structure to 0, and record length
      FillChar(StartupInfo, SizeOf(StartupInfo), 0);
      StartupInfo.cb := SizeOf(StartupInfo);
      // Execute application commandline
      if Windows.CreateProcess(nil, PChar(CommandLine),
        nil, nil, False, 0, nil, nil,
        StartupInfo, ProcessInfo) then
      begin
        try
          // Now wait for application to complete
          if Windows.WaitForSingleObject(ProcessInfo.hProcess, INFINITE)
            = WAIT_OBJECT_0 then
            // It's completed - get its exit code
            if Windows.GetExitCodeProcess(ProcessInfo.hProcess,
              ProcessExitCode) then
              // Check exit code is zero => successful completion
              if ProcessExitCode = 0 then
                Result := True;
        finally
          // Tidy up
          Windows.CloseHandle(ProcessInfo.hProcess);
          Windows.CloseHandle(ProcessInfo.hThread);
        end;
      end;
    end;
    

    From: http://www.delphidabbler.com/codesnip?action=named&showsrc=1&routines=ExecAndWait

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

Sidebar

Related Questions

I have a bat file that I should use to delete a part of
I have a simple bat script that copies files from an known directory to
I have a batch file that creates a scheduled task using schtasks like this:
So I have been writing to Environment.SpecialFolder.ApplicationData this data file, that upon uninstall needs
I have a BAT file that runs on startup via the group policy on
I have a .bat file like that: msg userA System will be restarted msg
I have a simple bat file that runs an access macro when executed, i
I have this .bat script which I use to maven package my application. Problem
I have a batch file that I have been using to install my C#
I have a batch file that calls a vbscript file. I am trying to

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.