Courseiva
mediumMultiple Choice

220-1102 Practice Question: Write a batch script that will copy a…

A technician needs to write a batch script that will copy a configuration file from a network share to the local system32 directory only if the file on the share is newer than the local copy. Which command should the technician use to perform this conditional copy?

⚠ Common exam trap

CompTIA A+ often tests the distinction between `copy`, `xcopy`, and `robocopy` switches, and the trap here is that candidates may choose `copy /y` thinking it is sufficient, overlooking the need for a timestamp-based conditional check that only `xcopy /d` provides.

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

✓

xcopy \\server\share\config.txt C:\Windows\System32\ /d /y

The `xcopy` command with the `/d` switch copies files only if the source file is newer than the destination file, and `/y` suppresses confirmation prompts. This meets the requirement of a conditional copy based on file timestamp comparison.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    copy /y \\server\share\config.txt C:\Windows\System32\

    Why it's wrong here

    The copy command overwrites the destination unconditionally; it compares no timestamps, so an older share file would still replace a newer local one. Copy is tempting as the obvious file-transfer tool, and it would be correct if the requirement were simply to place the file without any freshness check.

  • ✓

    xcopy \\server\share\config.txt C:\Windows\System32\ /d /y

    Why this is correct

    The /d switch makes xcopy copy only source files newer than the destination, satisfying the conditional requirement, while /y suppresses the overwrite prompt. This reliably updates config.txt in System32 only when the network share version is newer.

  • ✗

    robocopy \\server\share C:\Windows\System32 config.txt /mir

    Why it's wrong here

    The /mir switch mirrors the entire source directory tree, deleting extra files in the destination and copying everything, rather than comparing a single file's timestamp. Robocopy is tempting because it does perform timestamp-based conditional copying, but that behaviour requires the default copy mode or /xo, not /mir.

  • ✗

    move /y \\server\share\config.txt C:\Windows\System32\

    Why it's wrong here

    move deletes the source file after transferring it and performs no timestamp comparison, so it neither preserves the share copy nor honours the newer-file condition. Move is tempting when relocating a file permanently, which would suit a one-off migration rather than a repeatable conditional synchronisation script.

About these practice questions

One of 687 original 220-1202 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

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.