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?
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.
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.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With