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

  • Home
  • SEARCH
  • 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 6832969
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:55:23+00:00 2026-05-26T22:55:23+00:00

How to wait for a process to terminate before executing another process in a

  • 0

How to wait for a process to terminate before executing another process in a batch file? Let’s say I have a process notepad.exe that I need to kill before executing wordpad.exe. Then, when wordpad.exe is terminated, I need to launch notepad.exe again. How do I do 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-05-26T22:55:23+00:00Added an answer on May 26, 2026 at 10:55 pm

    Try something like this…

    @ECHO OFF
    
    PSKILL NOTEPAD
    
    START "" "C:\Program Files\Windows NT\Accessories\wordpad.exe"
    
    :LOOP
    PSLIST wordpad >nul 2>&1
    IF ERRORLEVEL 1 (
      GOTO CONTINUE
    ) ELSE (
      ECHO Wordpad is still running
      TIMEOUT /T 5
      GOTO LOOP
    )
    
    :CONTINUE
    NOTEPAD
    

    I used PSLIST and PSEXEC, but you could also use TASKKILL and TASKLIST. The >nul 2>&1 is just there to hide all the output from PSLIST. The SLEEP 5 line is not required, but is just there to restrict how often you check if WordPad is still running.

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

Sidebar

Related Questions

Is there a better way to wait for queued threads before execute another process?
Does blocking mode put that particular task in a Process Wait state, as i
I have a script that uses Parallel::ForkManager . However, the wait_all_children() process takes incredibly
I have a java class that creates a process, called child, using ProcessBuilder. The
I have written a program a.exe which launches another program I wrote, b.exe ,
I Have a shutdownhook, that is executed when the process is terminated. However the
I have a self upgrade process implemented where my main application exe launches an
I want to wait for a process to finish, but Process.WaitForExit() hangs my GUI.
The following doesn't work, because it doesn't wait until the process is finished: import
When does a windows workflow process go 'idle'? Does it wait a certain amount

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.