CScript.exe / wscript.exe

Run a VBScript / Windows Scripting Host (WSH) script.

'cscript' runs entirely in the command line and is ideal for non-interactive scripts.
'wscript' will popup Windows dialogue boxes for user interaction.

       cscript [options...] [ScriptName.vbs] [script_arguments]

       wscript [options...] [ScriptName.vbs] [script_arguments]


   ScriptName.vbs  : Text file containing VBS commands to be execute.
                     You must include the extension (normally .vbs).

   //T:nn      Timeout script after nn seconds.

   //nologo    Hide startup banner.
   //Logo      or Display banner (default)

   //I         Interactive mode. The default, and the opposite of /b.
   //B         Batch mode, which does not display alerts, scripting errors, or input prompts.

   //E:engine  Use engine for executing script e.g. //E:jscript

   //H:CScript Change the default vbs script host to CScript.exe
   //H:WScript Change the default vbs script host to WScript.exe (default)

   //Job:xxxx  Execute a WSF job.

   //S         Save current command line options for this user.

   //D         Starts the debugger.
   //X         Execute script in debugger.
   //U         Use Unicode for redirected I/O from the console.

It is important that all options are placed before the .vbs script (and any script arguments) in the command line, otherwise they will be passed as arguments to the script instead of being parsed by CSCRIPT.

Like many programs, cscript.exe will by default run as a 64 bit process on a 64 bit Operating System or it will run as a 32 bit process on a 32 bit Operating System. If your VBScript has any dependency on external programs, database connections etc this can make a difference.

To run a VBScript as a 32 bit process from a 64 bit OS use C:\Windows\SysWOW64\cscript.exe C:\scripts\demo.vbs

Call one VBScript from another.

This can be done as shown below, although it is often better to put everything in a single script and use Functions to split up the blocks of code.

Set objShell = CreateObject("WScript.Shell")"cscript C:\scripts\demo.vbs")

The VB Script scripting environment is installed by default on Windows 98 and all later versions of Windows.


Run the VB script called myscript.vbs:

C:\> cscript //nologo myscript.vbs

If the line above is saved as a batch script, double clicking the batch file will run the VBScript file.

“Throw a lucky man in the sea, and he will come up with a fish in his mouth” ~ Arab proverb

Related VBScript commands

.Exec - execute command.
.Run - Run an external Command.
.ShellExecute - Run an application in the Windows Shell.
Quit - Quit a VBScript.

Copyright © 1999-2023
Some rights reserved