Share via


Run ps1 files in a batch file

Question

Saturday, August 20, 2016 12:16 PM

I try to run a few ps1 files in a batch file.

Powershell.exe -File f1.ps1
Powershell.exe -File f2.ps1
Powershell.exe -File f3.ps1
...
Powershell.exe -File f8.ps1

Is there way to wait to finish one and then start next one automatically? I don't want to use "pause" command after each line

Thanks

All replies (2)

Saturday, August 20, 2016 3:55 PM ✅Answered

start /wait Powershell.exe -File f1.ps1

\(ツ)_/


Monday, August 22, 2016 6:24 AM

Hi lan3,

>>Is there way to wait to finish one and then start next one automatically? I don't want to use "pause" command after each line

You could also use: Wait-Process

https://technet.microsoft.com/en-us/library/hh849813.aspx

Or, using the Start-Sleep Cmdlet

https://technet.microsoft.com/en-us/library/ee177002.aspx

Best regards,

Andy_Pan

Please remember to mark the replies as an answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact [email protected].