easyMultiple ChoiceObjective-mapped
220-1202 Practice Question: That their Windows 10 computer runs a script…
A user reports that their Windows 10 computer runs a script every time they log in that maps a network drive, but the drive mapping fails intermittently. The script uses the 'net use' command. Which scripting element should be added to handle the failure gracefully and retry the mapping?
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
An exit code check and a loop to retry the mapping
This question tests basic error handling in scripting. Adding error-checking logic, such as checking the exit code of 'net use' and retrying if it fails, makes the script more robust. A simple 'if errorlevel' or 'if %errorlevel% neq 0' construct allows the script to retry the command instead of failing silently.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
A comment line explaining the net use syntax
Why it's wrong here
A comment line, denoted by REM in batch or # in PowerShell, serves purely for documentation within the script. While comments enhance readability for human administrators reviewing the code, they are entirely ignored by the script interpreter during execution. Therefore, adding a comment provides no functional impact on error handling, retry logic, or addressing any runtime issues like a failed net use command or a slow system.
- ✗
A variable to store the drive letter
Why it's wrong here
A variable, such as %drive_letter% in batch or $driveLetter in PowerShell, is used to store data that can be referenced and manipulated throughout a script. Storing the drive letter in a variable might make the script more flexible or easier to update, but it does not inherently provide any mechanism for detecting when a net use command fails. Variables do not implement error checking, conditional logic, or retry capabilities, which are essential for robust network operations.
- ✓
An exit code check and a loop to retry the mapping
Why this is correct
Checking the exit code, often via ERRORLEVEL in batch or $LastExitCode in PowerShell, allows a script to programmatically determine the success or failure of the preceding command. When combined with a loop, the script can detect a failure and then re-attempt the net use command multiple times. This approach provides crucial fault tolerance, enabling the script to overcome transient network issues or temporary server unavailability until the mapping succeeds or a predefined retry limit is reached.
- ✗
A 'pause' command after the net use line
Why it's wrong here
The 'pause' command in a script is designed to halt script execution until the user presses any key, primarily for debugging or to allow a user to read on-screen output. While it stops the script, it offers no automated error detection, no conditional logic to react to command failures, and no mechanism to retry a failed operation. Consequently, 'pause' does not contribute to making a net use command more reliable or addressing underlying system performance issues.
Go deeper
Related to this question
About these practice questions
This 220-1202 question is part of Courseiva's 495-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This 220-1202 practice question is part of Courseiva's free CompTIA certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the 220-1202 exam.