Search code examples
powershellsequencestart-process

Ensure Start-Process starts and finishes in order


PowerShell script has the following

Start-Process "D:\Script\EMAIL_Snapshot_Done.bat" $date, $scr_comp
Start-Process "D:\Script\BATCH_gup.bat"

How to ensure that first Start-Process starts and finishes BEFORE second Start-Process begins?


Solution

  • Something simple like this should do the trick.

    Start-Process "D:\Script\EMAIL_Snapshot_Done.bat" $date, $scr_comp -Wait
    

    You would have found this information on TechNet

    Wait-Process could also help but the simplicity of -Wait should not compare.