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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:32:26+00:00 2026-06-11T14:32:26+00:00

I am creating an application in C# which calls a batch file, then executes

  • 0

I am creating an application in C# which calls a batch file, then executes another .net exe file and then runs another batch file when the exe file is closed.

I can run the initial batch file and I can call the exe file using the Process.start(my.exe); method but how can I check when the exe file is finally terminated so that I can run the final batch file?

  • 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-11T14:32:27+00:00Added an answer on June 11, 2026 at 2:32 pm

    You can either call WaitForExit():

    myProcess.WaitForExit():
    

    When an associated process exits (that is, when it is shut down by the
    operation system through a normal or abnormal termination), the system
    stores administrative information about the process and returns to the
    component that had called WaitForExit(). The Process component can
    then access the information, which includes the ExitTime, by using the
    Handle to the exited process.

    Or, enable events and hook code on the exited event:

    myProcess.EnableRaisingEvents = true;
    myProcess.Exited += new EventHandler(myProcess_Exited);
    

    …

    private void myProcess_Exited(object sender, System.EventArgs e)
    {
        Console.WriteLine("Exit time:    {0}\r\n" +
            "Exit code:    {1}\r\nElapsed time: {2}", myProcess.ExitTime, myProcess.ExitCode, elapsedTime);
    }
    

    The key difference is synchronous or asynchronous. From the exited docs:

    There are two ways of being notified when the associated process
    exits: synchronously and asynchronously. Synchronous notification
    relies on calling the WaitForExit method to pause the processing of
    your application until the associated component exits. Asynchronous
    notification relies on the Exited event. In either case,
    EnableRaisingEvents must be set to true for the Process component to
    receive notification that the process has exited.

    Also, when you get to running batch file, check out this post:

    How to execute a batch file from C#?

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

Sidebar

Related Questions

I am creating an application which involves so many web-service calls. I am using
i am creating simple call filter application which restrict unwanted calls. i use following
I'm creating an android application which should parse a Json from a file or
i am creating an application which includes dynamic pages. actually, i created some dynamic
I'm creating an application which works on Froyo until Jelly Beans. I have two
I'm creating an application which communicates with the device via FT2232H USB/RS232 converter. For
I am creating an application which tracks the users location using GPS, stores the
I am creating Facebook application which get insights for user's page for multiple metric.
I am creating an application which produces some files/directories in my WebContent folder and
I am creating a small application which will perform say 4 different, time consuming

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.