VBS - How to pause script execution until a key is pressed?

How to pause script execution before pressing a key in VBScript? I need something that could pause program execution and wait until the left_arrow key is pressed.

+7
source share
1 answer

You do not have much choice. If you have a console script, and I assume that you do, you can read the input from the user, but it is registered only when [ENTER] is pressed. Thus, you can pause until you press the enter key. For instance:

WScript.Echo "Press [ENTER] to continue..." ' Read dummy input. This call will not return until [ENTER] is pressed. WScript.StdIn.ReadLine WScript.Echo "Done." 

There is also an old pause command from DOS days. However, shelling a new console window to start pause will result in a second window. You need to press a key in this window to return to your script. Probably not what you want.

But apart from third parties, VBScript has no methods for reading keystrokes at runtime.

+12
source

All Articles