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 logo
   //Logo      or Display logo (default)

   //I         Interactive mode
   //B         or Batch mode

   //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         Enable Active Debugging
   //X         Execute script in debugger
   //U         Use Unicode for redirected I/O from the console

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

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")


Run the VB script called myscript.vbs:

C:\> cscript 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


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

Quit - Quit vbs script

Copyright © 1999-2020
Some rights reserved