Wait For Process in a Batch File

A while ago I needed to wait for a process to end in a batch file, before the script continued.  I did it by using an If statement to create a ‘spoof’ loop, with a delay between each loop iteration of 5 seconds.  This example waits for the ‘Java.exe’ process to end before the script continues: