How to Set or Clear Write Protection via CMD on your USB flash drive

Vintaytime Staff
3 months ago / Updated - September 2, 2017
How to Set or Clear Write Protection via CMD on your USB flash drive

When copying files or formatting your USB drive, if your computer says that ‘The disk is write protected‘ or something related to it means that the disk drive is currently has write protection enabled or real-only attribute is set, even you can not delete any files from the USB unless the real-only attribute will not be remove.

As shown in the screenshot below, when I try to format a write protected USB drive, I see the message.

The disk is write protected Windows

How to know if write protection is enabled on USB?

Connect the USB and launch command prompt on your Windows PC as an administrator, type the following command in CMD and press Enter after each one:

Diskpart
List Disk
Select Disk X, where X is the disk number of your USB drive.
Attributes Disk

microsoft-cmd-check-disk-readonly

As you can see in the screenshot given above, if the value of ‘Current Read-only State‘ and ‘Read-only‘ is ‘Yes‘, that means write protection is currently enabled on your USB.

Enable / Disable USB write protection on Microsoft Windows

Follow the steps below:

  1. Connect the USB flash drive to your Windows PC.
  2. Launch Command Prompt (CMD) as Administrator (search ‘cmd’ in the start menu, right-click on Command Prompt and select ‘Run as administrator’).
  3. In the CMD type the following command and press enter after each command:
    Diskpart
    List Disk
    Select Disk X, where X is the disk number of your USB drive.

    microsoft-cmd-diskpart

  4. To enable write, deletion, and format protection, just type the following command and press enter:
    Attributes Disk Set Readonly

    microsoft-cmd-set-readonly

  5. To disable write, delete, and format protection:
    Attributes Disk Clear Readonly

    microsoft-cmd-clear-readonly

Write Protection work on other computers?

No, because it applies only to a computer or a PC that you used to enable the protection. If you connect the USB to another computer, then write protection will no longer work. Some USB manufacturers provide a hardware button or any software that enables write protection for all computers. Please check your USB manufacturer’s website for more information.