Operational Procedures

A technician must save legacy Windows Script Host code, which uses Dim and Set objShell = CreateObject("WScript.Shell"), so it runs on double-click. Which file extension is correct?

Show the answer

Correct answerA. .vbs

AWhy this is right: VBScript files use .vbs, and Windows Script Host runs them using this syntax.

BWhy not this: .bat files run Command Prompt commands and cannot parse VBScript statements.

CWhy not this: .js files also run under Windows Script Host, but they need JavaScript syntax, not Dim or Set.

DWhy not this: .ps1 files need PowerShell syntax and are not run by Windows Script Host.

The Dim and Set statements are VBScript syntax, and VBScript files use the .vbs extension, which Windows Script Host runs. A .js file also runs under Windows Script Host, but it holds JavaScript syntax and would not parse this code.