One of the most common tasks that I need to perform in Windows Script Host (WSH) scripts is to determine the script host (i.e., cscript.exe or wscript.exe) that's executing the current script. Determining the script host is important when, for example, a script uses the WScript object's Echo method repeatedly to display output. You don't want to use wscript.exe for such a script because if you did, the script would display a separate dialog box for each echoed string. Also, some scripts need access to certain properties of the WScript object that don't exist when the script host is wscript.exe (e.g., the StdIn, StdOut, and StdErr properties).
To allow my scripts to determine the script host, I wrote the ScriptHost function. Callout A in Listing 1 shows the VBScript version of this function. Callout A in Listing 2 shows the JScript version.
Both versions of the ScriptHost function use the WScript object's FullName property, which returns the fully qualified path and filename of the script host. The VBScript and JScript functions then use language-appropriate methods for extracting the filename and lowercasing it. . . .

