JM1
JM1

Reputation: 1715

PowerShell - How do I pause between processes in a script?

I have one script file that has multiple calls of this code:

Start-Process -NoNewWindow -FilePath $fullExeLocation -ArgumentList $argument
Start-Process -NoNewWindow -FilePath $fullExeLocation -ArgumentList $argument
Start-Process -NoNewWindow -FilePath $fullExeLocation -ArgumentList $argument

Each call of the process has a different location(filepath). I would like to pause between each of the processes for about 30 seconds or so.

How can I do that please?

Upvotes: 1

Views: 4321

Answers (1)

Abraham Zinala
Abraham Zinala

Reputation: 4694

Use the old legacy command of timeout followed by the seconds youd like for it to be timed out to, ex: timeout 30.

You can also just go with the native Powershell cmdlet of start-sleep, used just like timeout with a few more parameters. ex: start-sleep 30.

Start-Process -NoNewWindow -FilePath $fullExeLocation -ArgumentList $argument
Timeout /T 30
Start-Process -NoNewWindow -FilePath $fullExeLocation -ArgumentList $argument
Start-Sleep -Seconds 30
Start-Process -NoNewWindow -FilePath $fullExeLocation -ArgumentList $argument

Upvotes: 2

Related Questions