Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to wait for a process to terminate to execute another process in batch file

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?

like image 837
DogDog Avatar asked Nov 18 '11 04:11

DogDog


People also ask

Is there a wait command in batch?

The Sleep/Wait Command is a very useful command that is used to pause for a set amount of time while a batch script is being executed. To put it another way, this command makes it easier to run a command for a set amount of time.

What is @echo off in batch script?

batch-file Echo @Echo off @echo off prevents the prompt and contents of the batch file from being displayed, so that only the output is visible. The @ makes the output of the echo off command hidden as well.

What does %1 do in batch?

When used in a command line, script, or batch file, %1 is used to represent a variable or matched string. For example, in a Microsoft batch file, %1 can print what is entered after the batch file name.

What keys should you press to abort a batch file while running?

Ctrl+C. One of the most universal methods of aborting a batch file, command, or another program while it's running is to press and hold Ctrl + C . This keyboard shortcut sends a SIGINT signal, which cancels or terminates the currently-running program and returns you to the command line.


1 Answers

Use start /w programname to wait for the end of programname

START /W notepad ECHO Back from notepad   START /W wordpad ECHO Back from wordpad START /W notepad 
like image 64
RealHowTo Avatar answered Sep 18 '22 18:09

RealHowTo