This topic has not yet been rated - Rate this topic

ReadAll Method (Windows Script Host)

Returns all characters from an input stream.


                      object.ReadAll 
object

StdIn text stream object.

The ReadAll 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.

The following code demonstrates the use of ReadAll.

Dim Input
Input = ""

Do While Not WScript.StdIn.AtEndOfStream
   Input = Input & WScript.StdIn.ReadAll
Loop
WScript.Echo Input
var input = "";
while (!WScript.StdIn.AtEndOfStream)
{
   input += WScript.StdIn.ReadAll();
}
WScript.Echo(input);

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
How is the behaviour defined?
Does it behave the same on WScriptExec.StdOut and WScriptExec.StdErr compared to WScript.StdIn?
Does it block if there is nothing to read, or does it return immediately?
If it blocks, how can the user tell in advance whether there is anything to read to avoid blocking?
Does AtEndOfStream tell you if there is anything to read, or does it just tell you when the stream is closed?