iSumsoft » Resources »computer »Format Write Protected USB Drive Using CMD

How to Format a Write Protected USB Drive Using CMD

Can't format a USB pen drive because it is write protected? When I try to format a flash drive, pen drive or SD card, get the "disk is write protected" error message? Don't worry! There is an easy way to remove the write protection and format the USB flash drive or Pen drive without any hassle.

Step 1: Check and Unlock USB Flash Drive

If your computer tells you that the media is write-protected, check the switches on the storage device (USB or SD card). If the media has this switch, be sure to set the switch to write (unlock) instead of read-only.

In addition, if the USB flash drive is infected and attacked, you can also check it. You need to download anti-virus software and scan your USB flash drive. Delete the virus as soon as it is found, then remove the write protection from the read-only flash drive.

Step 2: Remove the write protection

There are many ways to remove the write protection of a USB drive from Windows. A popular method is to change the registry key, but this is scary for some people. A less complicated approach is to use diskpart.

Option 1: Use Regedit.exe to remove write protection

If you'd rather use the Windows Registry to remove write protection from a USB drive or SD card, use regedit to make the change.

Step 1: Connect removable device which is write protected with Windows PC.

Step 2: Go to the Start, type regedit in the Search box, then hit Enter to open the Registry Editor.

Step 3: In the Registry Editor, navigate to the following folder:


If the Storage Device Policies key is missing from your registry, you will be unable to remove USB Write Protection. Fortunately, you can try the following guide to create it by yourself.

Here is how to create a storage device polices key:

1. In Registry Editor, Navigate to registry key below: Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control.

2. Right-click Control key, and select New > Key, named StorageDevicePolicies.

Create storage device policies key

3. On the right panel of StorageDevicePolicies, right-click and select New DWORD and give it name as WriteProtect.

Create write protect DWORD

Step 4: Double-click the WriteProtect value in the right pane of StorageDevicePolicy.

Modify Write Protection value data

Step 5: Change the Value data from "1" to "0" and click OK to save your changes.

Replace value data with 0

Value data = 1, it means that Yes, write protect my USB storage device.

Value data = 0, it means that No, don't write protect my USB storage device.

Option 2: Remove Write Protection (Clear Read-only) Using CMD

Insert a USB flash drive into the computer, then follow these steps below:

1. Open a Command Prompt window as an administrator (Win+X, A).

2. Type in DISKPART and hit Enter.

3. Type in list disk and hit Enter. From the size of the disk, it's easy to find out which one is my removable disk.

4. Type in select disk 2 and hit Enter. (Disk 2 is the disk number of my USB drive, just repalce it with your disk number)

5. Type in ATTRIBUTES DISK and hit Enter key. If you can see the first line shows Current Read-only State: Yes then you can remove the write protection using command ATTRIBUTES DISK CLEAR READONLY.

Remove Write Protection via Diskpart Command

Step 3: Format USB Drive or Pen Drive using CMD

1. Insert a USB flash drive into a running computer.

2. Open a Command Prompt window as an administrator (Win+X, A).

3. Type diskpart in the new command line window that opens, then press Enter.

4. Type list disk, and then hit Enter. The list disk command displays all the disks on the computer. Note the drive number of the USB flash drive.

5. Type select disk X, where X is the drive number of the USB drive, and then press Enter.

6. Type clean, and then press Enter. This command deletes all data from the USB flash drive.

7. Type create partition primary, and then hit Enter. This command creates a new primary partition on the USB flash drive.

8. Type format fs=ntfs quick, and then hit Enter.

This will format the drive with the NTFS file system. If you wish to use FAT32 file system instead of NTFS, please use Format fs=FAT32 Quick command.

9. Type active, and then press Enter.

Format USB drive using command prompt