I want to run multiple commands at once with pause and but I'm not sure how. Here's my current code:
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
ipconfig /registerdns
ipconfig /flushdns
Regards
I did try it with Start-Sleep
, I don't get any solution.
If I understand your question, you would like to run multiple processes but force the previous to complete its process before allowing the next to run.
If this is the case then start-process
should be able to help with this utilizing the -wait
parameter, you can also hide the process window using the parameter -windowstyle
with the value hidden
.
You would use -filepath
parameter to specify the the application and then use the -argumentlist
for any arguments you want to pass through to that application:
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
Start-Process -FilePath C:\Windows\System32\ipconfig.exe -ArgumentList "/registerdns" -wait -WindowStyle hidden
Start-Process -FilePath C:\Windows\System32\ipconfig.exe -ArgumentList "/flushdns" -wait -WindowStyle hidden