Execute vbs command from cmd without a saved vbs file


How can one run a vbs command from cmd when the command is not saved?

For example to run a powershell command which has not been saved one can simply use powershell "get-childitem", where get-childitem is the command we want to use. We do not need to save a powershell file to run the command.

Let’s say we want to run the vbs command Wscript.Echo Date() without saving a vbs file first, how can we do that?

I’m not looking to do this from a .bat file. I really am looking to embed a vbs script in a node.js script. I realize that this is not heavily reflected in the questions title :-/ I want to use exec and embed the vbs. It’s important that there’s no files other than the one js.

If I could run the vbs command from the cmd console without the use of any files then I could run the command from node.js without the need for any other files.

I don’t think Is it possible to embed and execute VBScript within a batch file without using a temporary file? answers this as it’s concerning using a batch file.


Open a command prompt window and run cscript /? which runs *.vbs file on console or execute wscript /? which runs a *.vbs file with a graphic window. See also Microsoft TechNet article Using the command-based script host (CScript.exe) and the other articles reference in this article.
This, I think, is about as close as you will get.
@JNevill could be, but I’m look for something with no vbs file at all.
– Trevor
48 mins ago