A desktop support technician is troubleshooting an automated network drive mapping script intended to run during user logon on Windows client workstations. The script references environment variables using the `%USERNAME%` syntax, utilizes `IF NOT EXIST` conditional checks for folder paths, and executes command-line network utility commands. Double-clicking the file results in a Windows Script Host runtime error indicating invalid syntax. Which of the following actions will resolve the execution failure while preserving the current script code?
- Change the script file extension from `.vbs` to `.bat` so it runs natively within the Windows Command Prompt interpreter.Answer
- BChange the file extension to `.ps1` and modify the PowerShell execution policy to `RemoteSigned`.
- CChange the file extension to `.sh` and insert a `#!/bin/bash` shebang line at the beginning of the file.
- DExecute the file using the `cscript.exe` command-line host with the `/b` switch enabled.
Answer
Change the script file extension from `.vbs` to `.bat` so it runs natively within the Windows Command Prompt interpreter.
The script code provided uses standard Windows Batch syntax (`%USERNAME%` for environment variables, `IF NOT EXIST` for conditionals, and command-line utility calls). Saving a batch file with a `.vbs` extension forces Windows to run it through Windows Script Host, which generates a syntax error. Renaming the extension to `.bat` ensures `cmd.exe` interprets the script natively.
Step-by-Step Solution
Key Concept
Basic Scripting Languages and File Extensions