msgbartop
A chronological documentation test project, nothing serious, really!
msgbarbottom

23 May 2011 Clear Read-Only flag on Disk in Windows 7 using Diskpart

Posted by

This is a short HOWTO clear the read-only/readonly flag/attribute on a disk in Windows 7 using the diskpart command from a Windows Command Prompt.

Warning!
Be sure to do this on the right disk since the diskpart command can do serious damage if you run it on the wrong disk.

  1. Open a command window by running the diskpart command from a Command Prompt
  2. Determine which disk you are going to modify:
  3. DISKPART> list disk
    
      Disk ###  Status         Size     Free     Dyn  Gpt
      --------  -------------  -------  -------  ---  ---
      Disk 0    Online          149 GB  1024 KB
      Disk 1    Online          465 GB   465 GB
  4. Select the disk you are going to modify
    DISKPART> select disk 1

    You have now selected disk 1

    list disk
    
      Disk ###  Status         Size     Free     Dyn  Gpt
      --------  -------------  -------  -------  ---  ---
      Disk 0    Online          149 GB  1024 KB
    * Disk 1    Online          465 GB   465 GB
  5. Clear the Read-Only attribute on the selected disk
    DISKPART> attributes disk clear readonly

The disk is no longe Read-Only protected.

If you would like to set the disk Read-Only again just do the same procedure and write

DISKPART> attributes disk set readonly

in the last operation.

When you are done modifying the disk attributes just issue the exit command

DISKPART> exit

and the diskpart windows will be closed.

Tags: ,

Reader's Comments

  1. |

    Thank you so very much, I have been looking everywhere for this solution best one i have found. Already took one card back and didn’t have to.
    Once again Ty worked like a charm after removing and reinserting

  2. |

    What if ….”diskpart failed to clear disk attributes” msg pop?

    • |

      Are you sure you did run diskpart with administrator rights?

      • |

        What if ….”diskpart failed to clear disk attributes” msg pop? using as administrator

  3. |

    how do you know wich one disk to select??

    • |

      You probably know the capacity/size of the disk you are going to modify and choose it.
      Try to remove disks if you have several of the same size to avoid working on the wrong disk.

  4. |

    Just installed Windows 7 yesterday for the first time and all went nice and smooth until this “read-only” problem started to pop-up. I did google the solution and came to this web site and did it like explained – all I can say it thank you big time cause it worked right away with no problems what so ever.

  5. |

    I did as you said every command got successfully executed but still it shows disk is write protected??

  6. |

    not working…i have sandisk pd bt same problem….pls help…urgent….contact me on email id(chintanshah0123@gmail.com) pls….

  7. |

    I tried it but still write protected. Are there still any other methods? Please help me. Thank you

    • |

      Sorry to hear that. This method worked for me so I have not done any more searching about this problem.

  8. |

    ive tried this… and afterwards i typed in “det dis” and i got the following:

    DISKPART> list disk

    Disk ### Status Size Free Dyn Gpt
    ——– ————- ——- ——- — —
    Disk 0 Online 298 GB 0 B
    Disk 1 Online 596 GB 7168 KB
    * Disk 2 Online 29 GB 0 B

    DISKPART> sel dis 2

    Disk 2 is now the selected disk.

    DISKPART> att dis clear readonly

    Disk attributes cleared successfully.

    DISKPART> det dis

    ChipsBnk Multi-Reader USB Device
    Disk ID: 00000000
    Type : USB
    Status : Online
    Path : 0
    Target : 0
    LUN ID : 0
    Location Path : UNAVAILABLE
    Current Read-only State : Yes
    Read-only : No
    Boot Disk : No
    Pagefile Disk : No
    Hibernation File Disk : No
    Crashdump Disk : No
    Clustered Disk : No

    Volume ### Ltr Label Fs Type Size Status Info
    ———- — ———– —– ———- ——- ——— ——–
    Volume 5 E RAW Removable 29 GB Healthy

    i need “current read only State” to be “no” as well…

    Any suggestions please email me at ballzac2000(at)hotmail.com.

    Thanks,

    Zacc

  9. |

    […]  1. How does the write blocking become effective between XP, Vista and 7? What steps between applying the registry key and the write protection coming into effect need to take place. In Windows XP and later a user can add/modify the registry value “WriteProtect” found in HKLMSystemCurrentControlSetControlStorageDevicePolicies to enable write blocking for USB devices. The StorageDevicePolicies key may not exist by default and must be added by an administrator. If the value is set to “00000001” then all newly connected USB drives will be write blocked. In the test that I performed on Windows 7 the effect was immediate, however according to an article on Howtogeek.com (1), on Windows XP; a restart is required when the key is initially added. 1. http://www.howtogeek.com/howto/windows-vista/registry-hack-to-disable-writing-to-usb-drives/- Not that the reg files provided are mixed up and the “EnableUSBWrite” sets the key to 00000000. 2. What windows subsystem is enforcing the write protection?Unsure. The Plug-and-Play manager receives notification that a drive has been connected and then queries a number of keys in the SYSTEM hive. I imagine that it looks for the StorageDevicePolicies key if it exists and acts accordingly. 2. Windows Registry Forensics, Carvey, p 110. 3. What happens to USB devices already plugged in when the write protection?If a USB device is currently connected when the registry key is changed it will remain writeable until it is removed and reconnected. 4. Can anything bypass the write protection offered by this registry key?Yes, using a hex editor will bypass this kind of write protection (but not a physical write blocker). 3. http://lowcostwin4n6.blogspot.com.au/2011/06/testing-my-software-write-blocker.html 5. Does this registry key protect MTP USB Devices?No. I performed a quick test using my Nexus 5 and saw that it mounted as a portable device. I then successfully copied a file onto the device even though write protection was enabled. 6.  Why does this registry key not protect non USB Devices? Unsure. I imagine it has something to do with the way that Windows checked the registry key before it mounts USB drives but not before it mounts hard drives or portable devices. It is possible to write protect hard disks using diskpart http://pario.no/2011/05/23/clear-read-only-flag-on-disk-in-windows-7-using-diskpart/ […]

  10. |

    sir , my sandisc pendrive is write protected
    plese send me on my email how to cancel write protection on my pen drive

    • |

      Hi Rajendra gupta,

      Why don’t you try to follow the instructions in the post and let me know what went wrong?

  11. |

    I tried the above mentioned commands.When I run the last command “attributes disk clear readonly” then I am getting the message as “Disk attributes cleared successfully” . But still when I try to format or paste something then I am getting the same message that disk is write protected. Plz guide me.

    • |

      Hi Ketaki,

      Are you sure you did run diskpart with administrator rights?

  12. |

    You guys need to unplug your drives and then plug them back in. Also, try rebooting your computer. For harddrives for example, setting the readonly bit will only work after a reboot (or possibly after remounting the drive).

  13. |

    I get this error, so apparently you need to run a check-disk to remove the dirty flag from the drive. chkdsk u: /f /r /x I have a exfat ssd on windows 7 and this happens every other month where it mounts as read only. If it tells you the drives in use, in task manager you can go view>select columns> image path name to see whats loading off the drive. Not 100% but may help.

  14. |

    @Hans-Henry & @Solver, Morning! I’ve been searching a method myself for un-setting the read-only state on my sandisk drive. Nothing seems to work. I followed this procedure every step of the way, but nothing seems to work.

    I got to this so far:

    DISKPART> list disk

    Disk ### Status Size Free Dyn Gpt
    ——– ————- ——- ——- — —
    Disk 0 Online 250 GB 0 B
    Disk 2 Online 16 GB 0 B

    DISKPART> sel dis 2

    Disk 2 is now the selected disk.

    DISKPART> att dis clear readonly

    Disk attributes cleared successfully. (This is really annoying… Appearently all worked out just fine…)

    DISKPART> det dis

    ChipsBnk Multi-Reader USB Device
    Disk ID: 00000000
    Type : USB
    Status : Online
    Path : 0
    Target : 0
    LUN ID : 0
    Location Path : UNAVAILABLE
    Current Read-only State : Yes
    Read-only : No
    Boot Disk : No
    Pagefile Disk : No
    Hibernation File Disk : No
    Crashdump Disk : No
    Clustered Disk : No

    That current Read-Only State has never changed, no matter what I do. After that, I typed exit as instructed, removed the flashdrive then plug it back in but nothing seems to work. I even repeated every step but after I typed “exit” and removed the flashdrive I even went ahead and reboot my PC, still, no changes took place. is there anything I’m missing? I’d very much appreciate if you could please guide me a little bit on this matter. Thanks in advance.

    jogs2602@yahoo.com

  15. |

    Try and close any Control Panel, My Computer and any folder you have opened. Then insert memory card and close autorun. Run the procedure. In My Computer eject memory card dismount dismount, reinsert. See if that helps!

  16. |

    Many thanks – worked like a charm!!! i had a 3TB backup drive that all of the sudden went READ-ONLY, and i’ve been ‘stuck’ with it like that for almost a year!!!

    this solution is too easy ( as they say in the military )

    THANK YOU x 1000!!

  17. |

    I tried the above mentioned commands.When I run the last command “attributes disk clear readonly” then I am getting the message as “Disk attributes cleared successfully” . But still when I try to format or paste something then I am getting the same message that disk is write protected. Plz guide me.

  18. |

    Hello Everyone,

    I was able to resolve my issue. Here is what I did.

    Firstly, there are a series of options in the Group Policy Object Editor that deal with read/write permissions on hard drives and removable media. I basically changed their individual settings from “Not configured” to “Disabled”.

    Start -> Run… -> gpedit.msc -> OK

    Computer Configuration -> Administrative Templates -> System -> Removable Storage Access

    In here I disabled all of the “Deny read access/write access” options; you may only want to disable the ones relating directly to the type of media that you want to access.

    Here are the ones I changed:

    Removable Disks: Deny execute access
    Removable Disks: Deny read access
    Removable Disks: Deny write access
    Double-click each one and select the ‘Disabled’ radio button.
    i got same problem but try this

  19. |

    GREAT page. Searched and searched, I didn’t found the solution anywhere as here. Still a mystery why the (initially GPT, now MBR, always with exFAT partition) disk got readonly! THANK YOU!!

  20. |

    Thanks for this tip that solved my problem.

  21. |

    ^^^^^ i got the same problem

  22. |

    i have tried several time but unfortunately enough the command does not work. it give the message that “the clear read-only is successfully”. but remain problem unsolved. and when i display the attribute disk. the “current read-only” is is switched “YES”; I Need help for that

  23. |

    my flash driver prompt me to format whenever insert in pc port.

  24. |

    doest work :(

  25. |

    My issue was the launcher for a game(Tribes Ascend) would somehow always lock up a file and keep the drive in read only. I used the task manager option to view which exe’s are using the drive. All I had to do is kill the launcher and run it again and it worked.

  26. |

    Hi,
    This method,
    “DISKPART> attributes disk set readonly”
    will change the Read Only to No, but the
    Current Read Only State won t. Still NO :-(
    BW
    Ssan

  27. |

    hi, i try attributes vol set readonly

    and i’ve this error
    error of the Virtual Disk Service :
    the operation is not supported on removable media