StdOut.Read - VBScript


The StdOut.Read() command in VB Script reads data from the standard output stream (stdout), which is typically generated by scripts, programs, or processes running in a command prompt or PowerShell. It retrieves the content displayed in the command window or terminal, allowing you to capture and manipulate text output for further processing or display.




  • length (Optional): Specifies the maximum number of characters to read from the standard output stream. If omitted, it will read the entire output.


This command does not have any specific options or flags.


Simple Read:

Dim output = StdOut.Read()

Read Limited Characters:

Dim output = StdOut.Read(100) ' Reads the first 100 characters of the standard output

Complex Usage:

' Captures the output of a command and displays it in a message box
Dim command = "dir"
Dim output = StdOut.Read()
MsgBox (output)

Common Issues

  • Empty Output: If the command executed does not generate any standard output, the Read() method will return an empty string.
  • Truncated Output: If the length parameter is specified and the output is longer than the specified number of characters, only the specified portion will be read.


The StdOut.Read() command can be used in conjunction with other VB Script commands for advanced scripting tasks. For example:

  • Pipe Output to File: Save the standard output to a text file.
Dim output = StdOut.Read()
CreateObject("Scripting.FileSystemObject").OpenTextFile("output.txt", True).Write output
  • StdErr.Read(): Reads data from the standard error stream (stderr).
  • WriteLine(): Writes a line of text to the standard output stream.
  • InputBox(): Displays a dialog box prompting the user to enter text.