How to directly call console-mode VBScript programs from the command-line

The normal procedure to call a console-mode VBScript is to execute it through cscript.exe

cscript /nologo scriptname.vbs parm1 parm2 ...

In order to avoid having to type "cscript /nologo" for calling VBScripts, a new file extension can be registered. (This works with Windows 2000, XP or newer). After that, the script can be directly called from the command line:

scriptname parm1 parm2 ...

The following commands can be used to register the file extension ".vbs_console" for console-mode VBScript files. (This registration is stored permanently within the Windows system registry):

assoc .vbs_console=VBS_Console_File
ftype VBS_Console_File="%%SystemRoot%%\system32\CScript.exe" //E:vbs //nologo "%%1" %%*

Additionally, the new file extension ".vbs_console" has to be added to the PATHEXT environment variable.

set pathext=.vbs_console;%pathext%

(The Scripts have to be renamed from *.vbs to *.vbs_console)

Author: Christian d'Heureuse (www.source-code.biz, www.inventec.ch/chdh)
Index