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

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

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 behaviors.

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 executing 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  Windows CMD.exe or Command Shell Tutorial with Examples

Sleep In MS-DOS

Sleep In MS-DOS

1 Response

  1. 10/06/2018

    … [Trackback]

    […] Find More Informations here: […]

Leave a Reply

Your email address will not be published. Required fields are marked *