VBscript write to command console

Filip 831 Reputation points

Hello everybody.
Can i run .vbs file in the command line and get there printed output?
I tried :

Dim StdOut : Set StdOut = CreateObject("Scripting.FileSystemObject").GetStandardStream(1)  
WScript.Echo "Hello"  
WScript.StdOut.Write "Hello"  
WScript.StdOut.WriteLine "Hello"  
Stdout.WriteLine "Hello"  
Stdout.Write "Hello"  


Thanks for help.

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
23,931 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Viorel 82,911 Reputation points

    Use WScript.Echo "Hello" line only (remove other lines) and start the script in console using this command: cscript test.vbs.

  2. MotoX80 23,651 Reputation points

    Windows has 2 VB script processors, WScript.exe (GUI) and CScript.exe (console). To get the output to display in a command prompt you have to use cscript.exe.

    cscript.exe C:\MyScriptsFolder\MyScript.vbs  

    If you just type in the script name Windows will use the default which is wscript.exe. You can change that from an admin command prompt.

    cscript.exe //H:CScript  


    No comments