How To Pause and Resume Powershell and Cmd Scripts In Windows With Examples?

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/pause-resume-powershell-cmd-scripts-windows-examples/
PINTEREST
PINTEREST
INSTAGRAM

Powershell is as its name suggest powerful language. I have very good features and libraries. In this tutorial we will look how to pause powershell in different ways and different behaviours.

Pause And Wait Input

We may want to pause the current shell and wait an input from the user. This is very useful if we need more specific input from the user like selecting a menu or an option. In this example we will read input from users interactive shell which will pause the execution of the shell up to an input is entered by the user.

Pause And Wait Input
Pause And Wait Input

Pause For Specified Time Period

We have another options where we can specify the time as seconds to wait. This will actually sleep the current running interactive process and wait for the given time. After the sleep period end the script will resume excuting from point where it left. In this example we will write "I will sleep" in the console and then sleep for 5 seconds after the sleep we will write "I woke up".

Sleep In MS-DOS

MS-DOS or cmd also supports for sleeping functionality. This is a bit different from previous examples. This code is more elegant and simple. We will implement code in a single line or one liner. we will issue pause command and print the output to null. We can use this line as in a batch file.

LEARN MORE  Get-Service Service Management With Windows Powershell From Command Line

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/pause-resume-powershell-cmd-scripts-windows-examples/
PINTEREST
PINTEREST
INSTAGRAM

Leave a Reply

Your email address will not be published.