question

Filip-2434 avatar image
0 Votes"
Filip-2434 asked MotoX80 edited

VBscript write to command console

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.


not-supported
a.png (31.5 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @Filip-2434 ,
Unfortunately, vbscript is currently not supported in the Q&A forums, the supported products are listed over here: https://docs.microsoft.com/en-us/answers/products (more to be added later on). Thank you for your understanding.

0 Votes 0 ·
MotoX80 avatar image
0 Votes"
MotoX80 answered MotoX80 edited

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





capture.jpg (84.2 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Viorel-1 avatar image
1 Vote"
Viorel-1 answered Filip-2434 commented

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


· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hello @Viorel-1 .
It show me a message box but I want to get the "Hello" output seen in command line.
I mean when i run it in cmd i want to see in the console the output.
Is it possible to do?
Thanks for answare.

0 Votes 0 ·

When I execute your script using the instructions provided by Viorel-1 (use cscript) I get:

 Hello
 HelloHello
 Hello
 Hello

1 Vote 1 ·

Hello @SimpleS.
Do you get this output to cmd console or as pop up messages?
Because i got all time only pop up messages and I want get an output to console from where i run it.
Thanks for answare.

0 Votes 0 ·

I think that it is possible. Inside the test.vbs file, use WScript.Echo "Hello". Open a console (Command Prompt), go to your folder and type cscript test.vbs.

0 Votes 0 ·