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?
How to wait for a process to terminate before executing another process in a
Share
Try something like this…
I used
PSLISTandPSEXEC, but you could also useTASKKILLandTASKLIST. The>nul 2>&1is just there to hide all the output fromPSLIST. TheSLEEP 5line is not required, but is just there to restrict how often you check if WordPad is still running.