A desktop support technician is writing a Windows Batch script (`.bat`) to automate system profile configuration during user logon. The script must reference the currently logged-in user's account name dynamically from the system environment. Which of the following syntaxes correctly formats an environment variable within a Windows Batch script?
- %USERNAME%Cevap
- B$USERNAME
- C$env:USERNAME
- Dvar USERNAME
Cevap
Enclosing the variable name between percent signs (%USERNAME%) is the correct construct for environment variables in Windows Batch scripts.
In Windows Batch (`.bat`) scripting, environment variables are referenced by surrounding the variable name with percent signs, such as %USERNAME%. When the batch file executes, the Command Prompt interpreter replaces the expression with the actual environment variable value.
Adım Adım Çözüm
Anahtar Kavram
Windows Batch Environment Variable Syntax
Tahmini Süre:1m 0s