To output to the command console window you can do this using:
WScript.Echo returnVal
or
WScript.StdOut.WriteLine returnVal
But you must use the CScript host for this to work, for example:
cscript.exe myscript.vbs
WScript is the GUI host and so has no knowledge of the standard input/output/error/aux streams. Trying to do WScript.StdOut.WriteLine will result in the following error dialogue:
---------------------------
Windows Script Host
---------------------------
Script: d:\myscript.vbs
Line: 12
Char: 1
Error: The handle is invalid.
Code: 80070006
Source: (null)
---------------------------
OK
---------------------------
In a CScript.exe script you can still pop up GUI message dialogues using:
Msgbox "Hello World!"
Using WScript.Echo in a WScript host will display the message in a popup dialogue instead of printing to the command line window.
For more information see:
Write Method (Windows Script Host)
For more information on the differences between WScript and CScript and how to switch between them:
Sesame Script Stop and Go (MS TechNet)
The difference between Cscript and Wscript is that Cscript is the
command-line version of the script host and Wscript is the graphical
version. This difference isn’t really noticeable unless your script
uses the Wscript.Echo command.