How to Fix the "Disk Is Write-Protected" Error
Level-by-level solution, from the physical switch to DiskPart, with no lost files if you follow the right order.
Windows says "the disk is write-protected" when you try to copy, delete or format a USB drive or SD card. First, check the simplest thing — it fixes half the cases without touching any software.
Level 1: the physical switch
Many USB drives and almost all SD cards have a small physical switch on the side. If it's in the "Lock" position, that's the whole cause — slide it to the opposite position and you're done.
Level 2: removing the "Read-only" attribute
Right-click the drive in File Explorer → Properties → uncheck the "Read-only" box if it's checked.
Level 3: DiskPart
If the previous steps don't fix it, this command removes the protection at the disk level itself:
diskpart
list disk
select disk N
attributes disk clear readonly
Warning: replace "N" with your USB's actual number
(check it with list disk before selecting — choosing the
wrong disk could affect a different drive, including your main disk).
This command doesn't delete files by itself, but it's a step that
requires precision.
If none of this works: it could be a virus
Some types of malware turn on write protection as part of their behaviour. Scan the drive with your antivirus before assuming the problem is physical.
Last resort: formatting
Warning: formatting erases all the drive's content. Only go this far if the previous steps didn't work and you no longer need (or have already copied elsewhere) whatever was on it.
If the problem always persists, on any PC
That points more toward a physical failure of the device itself than a Windows setting — in that case, no command is going to fix it permanently, and it's worth replacing the drive.
Frequently asked questions
Why does my USB say protected if the switch is unlocked?
It could be due to the 'Read-only' attribute in Windows, damaged configuration on the disk itself, or, in less common cases, a virus. Try the following levels in this guide in order.
Does the DiskPart command delete my files?
The 'attributes disk clear readonly' command doesn't delete files by itself — it only removes the protection. The risk is in selecting the wrong disk, which is why it's important to confirm the right number with 'list disk' before continuing.
Could a virus be the cause of the write protection?
Yes, it's a genuine cause, though less common than a simple locked switch. If none of the above works, scanning the drive with an antivirus is a reasonable step before considering formatting.