Read Method (Windows Script Host)

Returns a specified number of characters from an input stream.



  • object
    StdIn text stream object.

  • characters
    Integer value indicating the number of characters you want to read.


The Read method returns a string. The StdIn, StdOut, and StdErr properties and methods work when running the script with the CScript.exe host executable file only. An error is returned when run with WScript.exe. Reading begins at the current position pointer location and moves forward one character at a time.

The Read method does not return until the enter key is pressed. Only the number of characters requested will be returned. Any additional characters will be returned on subsequent calls to the Read, ReadLine, or ReadAll methods.


The following code uses the Read method to get a character from the keyboard and display it on the console.

Dim Input
Input = ""

Do While Not WScript.StdIn.AtEndOfLine
   Input = Input & WScript.StdIn.Read(1)
WScript.Echo Input
var input = "";
while (!WScript.StdIn.AtEndOfLine)
   input += WScript.StdIn.Read(1);

Applies To:

StdIn Property (WScript)

See Also


Write Method (Windows Script Host)

TextStream Object