VBscript write to command console

Filip 831 Reputation points
2021-04-14T09:21:06.297+00:00

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"  

87672-a.png

Thanks for help.

Community Center Not monitored
{count} votes

2 answers

Sort by: Most helpful
  1. Viorel 122.5K Reputation points
    2021-04-14T11:12:50.243+00:00

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

    2 people found this answer helpful.

  2. MotoX80 36,291 Reputation points
    2021-04-20T13:44:59.073+00:00

    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  
    

    89582-capture.jpg

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.