VBScript code cannot be run directly from CMD. You need to run it with the proper interpreter, which normally is either wscript.exe
(GUI-based, default) or cscript.exe
(console-based) on Windows systems. Put your code in a .vbs file and then run that file with the respective interpreter:
wscript.exe //NoLogo "C:\path\to\script.vbs"
or
cscript.exe //NoLogo "C:\path\to\script.vbs"
If your question is how to run VBScript commands interactively at a prompt (like Python's or Ruby's interactive mode for example): the builtin interpreters don't provide that feature. Their "interactive" parameter (//i
) has a different meaning. It allows interaction (error messages, input prompts, ...) between script and user as opposed to batch mode (//b
) that suppresses all user interaction so that the script runs uninterrupted in the background.
However, it's pretty easy to write small wrapper scripts that allow running code directly from the commandline (like Perl) or provide an interactive prompt (like Python or Ruby).