Some VBScripts are intended to be run from the command line version of the VBScript script host, while others may be intended to run from the GUI version. This code will identify if the script is running from the command line (“cscript”) or GUI (“wscript”).
' ' Since some scripts are intended for command-line use ' rather than GUI use, it can be helpful to know whether ' a script has been called from the command line (cscript) ' or the GUI (wscript). This function will return either ' "cscript", "wscript", or "UNKNOWN" depending on how the ' script was called. ' Function getScriptHost() scriptHost = LCase(WScript.FullName) theHost = "" if instr(1,scriptHost,"cscript.exe") then theHost = "cscript" end if if instr(1,scriptHost,"wscript.exe") then theHost = "wscript" end if if theHost = "" then theHost = "UNKNOWN" end if getScriptHost = theHost end function