ReadLine Method (Windows Script Host)


Returns an entire line from an input stream.



StdIn text stream object.

The ReadLine 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. A line is a sequence of characters that ends with a newline character.


Although this method extracts the newline character, it does not add it to the string.

Legacy Code Example

The following code demonstrates the use of the ReadLine method.

Dim StdIn, StdOut
Set StdIn = WScript.StdIn
Set StdOut = WScript.StdOut

Do While Not StdIn.AtEndOfStream
     str = StdIn.ReadLine
     StdOut.WriteLine "Line " & (StdIn.Line - 1) & ": " & str
var stdin = WScript.StdIn;
var stdout = WScript.StdOut;

while (!stdin.AtEndOfStream)
     var str = stdin.ReadLine();
     stdout.WriteLine("Line " + (stdin.Line - 1) + ": " + str);