.Echo - VBScript


The .Echo command in VBScript is used to display a message on the screen or write it to a specified output device. It is primarily used for debugging purposes, to display variable values, error messages, or any other information that needs to be communicated to the user.


.Echo [**|** outputArgumentList]


| Parameter | Description |
| outputArgumentList | (Optional) One or more variable names, expressions, or literals to be displayed. |




Display a simple message:

.Echo "Hello world!"

Display the value of a variable:

Dim name = "John Doe"
.Echo "Name: ", name

Write to a file:

Dim fso, file
Set fso = CreateObject("Scripting.FileSystemObject")
Set file = fso.OpenTextFile("output.txt", 2) ' Append mode
.Echo "This is a test message." >> file

Common Issues

  • Ensure that the output device (e.g., the command window) is open and visible before using .Echo.
  • If no output is displayed, check if any error messages were generated earlier in the script.
  • When writing to a file, make sure the file path is valid and that the file can be opened for writing.


The .Echo command can be integrated with other VBScript commands to create more complex scripts. For example:

Dim wscript, shell
Set wscript = CreateObject("WScript.Shell")
Set shell = wscript.Exec("cmd /c echo Hello world!")
shell.StdOut.ReadAll ' Read and display the output of the command
  • WScript.Echo
  • Debug.Print
  • Console.WriteLine (in PowerShell)