In Windows batch scripting, how are loop variables denoted when used inside a script?

Study for the SANS560 GIAC Penetration Tester (GPEN) Test. Study with flashcards and multiple choice questions, each question has hints and explanations. Get ready for your exam!

Multiple Choice

In Windows batch scripting, how are loop variables denoted when used inside a script?

Explanation:
Loop variables in Windows batch files use double percent signs. In a batch script, the FOR loop variable must be written with two percent characters (for example, FOR %%F IN (*.txt) DO echo %%F). The double percent avoids confusion with command-line parameter expansion, which uses a single percent when typing directly at the prompt (FOR %F IN (*.txt) DO echo %F). Other symbols like $ or @ aren’t used to denote FOR loop variables in batch scripts.

Loop variables in Windows batch files use double percent signs. In a batch script, the FOR loop variable must be written with two percent characters (for example, FOR %%F IN (.txt) DO echo %%F). The double percent avoids confusion with command-line parameter expansion, which uses a single percent when typing directly at the prompt (FOR %F IN (.txt) DO echo %F). Other symbols like $ or @ aren’t used to denote FOR loop variables in batch scripts.

Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy