Soru

Zorluk: OrtaBasic Scripting Languages and Constructs

An IT technician is updating a Windows legacy Batch script (.bat) designed to map network drives and log workstation startup details. The script needs to reference the system-defined variable containing the computer name of the domain controller that authenticated the user session. Which of the following represents the correct construct and syntax to retrieve this value within the Batch file?

  1. %LOGONSERVER%Cevap
  2. B
    $env:LOGONSERVER
  3. C
    $LOGONSERVER
  4. D
    "LOGONSERVER"

Cevap

The construct %LOGONSERVER% is the correct syntax for referencing the authenticating domain controller environment variable within a Windows Batch (.bat) script.
In standard Windows Batch (.bat) scripts, environment variables are dereferenced by enclosing the variable name in percent signs (%LOGONSERVER%). The LOGONSERVER environment variable holds the name of the domain controller that authenticated the active logon session.

Adım Adım Çözüm

1
Identify the target scripting environment from the scenario.
The scenario specifies a Windows legacy Batch script (.bat) executed by cmd.exe.
Scripting environments use distinct syntactical conventions for variable dereferencing.
2
Determine the proper variable wrapping for Windows Batch environment variables.
Windows Batch scripts require surrounding percent signs (e.g., %VARIABLE%) to expand the stored environment variable.
The system environment variable LOGONSERVER stores the name of the authenticating domain controller.

Anahtar Kavram

Windows Batch Environment Variable Syntax
Bu soruyu puanla