/
/

How to Enable or Disable Write Protection for a Disk Drive in Windows

How to Enable or Disable Write Protection for a Disk Drive in Windows blog banner image

Having a data protection plan is key to ensuring that your organization’s sensitive and important information is always kept safe. And for a lot of organizations, especially ones that use portable USB drives, this can involve making their disks write-protected.

There are a couple of ways to enable this feature. In this article, we’ll discuss how to enable or disable write protection using Command Line and Registry Editor.

What is write protection?

Generally speaking, a computer inputs and edits information on a disk drive as you’re using it. However, if you enable write protection on a disk drive, this will prevent data from being written or altered on the drive. This means that you can no longer add, modify, or delete files from the disk until write protection is disabled again.

Requirements

Before you get started, ensure you have everything you require to complete the task. For this guide, you’re going to need the following:

  • A Windows 10 computer and an account that has administrator access.
  • A removable or fixed disk with an accessible volume.
  • Optional but not required: familiarity with Command Line or Windows Registry.

Method 1: Enable or disable write protection via DiskPart (Command Line)

The first way to enable write protection is by using DiskPart. This has to be done through Command Line, so make sure you have the necessary administrator permissions before proceeding.

  1. Open the Start Menu.
  2. Search for Command Prompt, and open the program.
  3. Type diskpart > Enter.
  4. Input list disk to see all disk drives currently connected to your computer.
  5. Select your target disk (example: Disk F) and type select disk f > Enter.
  6. Type attributes disk set readonly > Enter.
  7. That disk will now be write-protected. You can now close Command Prompt.

Method 2: Enable or disable write protection via Registry Editor

The Registry Editor is another tool you can use to enable write protection. However, do keep in mind that this method can only be used on USB disk drives. And, since the Windows Registry contains advanced computer controls and configurations, make sure you have a backup before starting.

  1. Open the Start Menu.
  2. Search for Registry Editor and open it.
  3. Input this into the address bar:
    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\StorageDevicePolicies
  4. Right-click the StorageDevicePolicies key > New DWORD (32-bit) Value.
  5. Name the new file WriteProtect.
  6. Double-click the Write Protect File and set the value to to enable write protection. To disable it, set it to instead.
  7. Click OK. 
  8. Restart your computer. Changes should apply once the system boots back up.

If you can’t find StorageDevicePolicies, you have to create it before proceeding with the next steps. Here’s how to do so:

  1. Navigate to this address:
    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control
  2. Right-click the Control key > New Key.
  3. Name the new key StorageDevicePolicies.

Notes and use cases

Each method has slightly different effects, and there are pros and cons to using one over the other, depending on your specific situation. Here are some notes on the methods provided in this guide:

  • If you use the Command Line method, the effects will be immediate and affect the whole drive.
  • The Windows Registry method can only be used for USB removable devices.
  • Some devices, commonly in SD cards, have hardware-based write protection switches. If the device you’re working on does have that, it cannot be overridden by software commands. You have to override the hardware switch manually.

Why use it?

If the disk drive contains important data, write protection will prevent the accidental deletion and modification of any data on it. This enhances your organization’s security by locking the content of portable drives and protecting their integrity even while they’re out of the office premises.

The feature is also especially useful for forensic, archival, and public-access information. This way, people who don’t have the necessary access and permissions will be able to view the data contained within the drive, but they won’t be able to make changes to it.

Who might use a write-protected disk?

IT professionals, system administrators, digital forensic experts, and anyone interested in cybersecurity. Write protection is an important tool in overall endpoint security management, so it’s something all organization IT departments should consider mastering.

Troubleshooting options for making disks write-protected

When working with Command Line or the Windows Registry, things might not always go the way you expect them to. Here are some common issues that come up when configuring write protection and how you can solve them:

DiskPart returns “Disk is not editable”

Make sure that the disk is not in use and that no partitions are mounted.

The registry key is missing

If the registry key is missing, you’ll have to complete it manually. Follow this step-by-step guide to do that.

Still can’t write after disabling write protection

Try checking for a physical write-protect switch. Software won’t be able to override that, so you’ll have to turn it off manually.

Frequently Asked Questions: Enabling write-protected disk

Does this work for all USB flash drives?

Yes. This guide should work as long as the drive doesn’t have a physical write-protect switch.

Will enabling write protection via DiskPart make the drive read-only on all PCs?

Not necessarily. The drive will be read-only on Windows machines that respect the read-only flag. However, some operating systems may not honor or be able to read the read-only flag.

Can I still format a write-protected drive?

No. Write protection will prevent any files from being deleted from the drive. If you try to format it while it’s still read-only, the formatting will fail.

Final thoughts on how to change write protection on USB drives and fixed storage disks

Write protection is an incredibly useful and practical feature that secures and protects data on both removable and fixed storage media. With useful computer tools, such as DiskPart and the Windows Registry, you can quickly enable or disable write protection as needed.

Every organization has unique needs and circumstances, and it’s important to take those into account when deciding how to implement write protection for your disk drives. Some devices already have write protection built into their hardware, so make sure to verify that before trying out software options.

DiskPart is a great option if you’re looking for broader controls. And if you’re working with USB drives, the Windows Registry might be your best choice. Whatever choice you make, just ensure it’s the one that will work best to accomplish your goals.

You might also like

Ready to simplify the hardest parts of IT?
×

See NinjaOne in action!

By submitting this form, I accept NinjaOne's privacy policy.

NinjaOne Terms & Conditions

By clicking the “I Accept” button below, you indicate your acceptance of the following legal terms as well as our Terms of Use:

  • Ownership Rights: NinjaOne owns and will continue to own all right, title, and interest in and to the script (including the copyright). NinjaOne is giving you a limited license to use the script in accordance with these legal terms.
  • Use Limitation: You may only use the script for your legitimate personal or internal business purposes, and you may not share the script with another party.
  • Republication Prohibition: Under no circumstances are you permitted to re-publish the script in any script library belonging to or under the control of any other software provider.
  • Warranty Disclaimer: The script is provided “as is” and “as available”, without warranty of any kind. NinjaOne makes no promise or guarantee that the script will be free from defects or that it will meet your specific needs or expectations.
  • Assumption of Risk: Your use of the script is at your own risk. You acknowledge that there are certain inherent risks in using the script, and you understand and assume each of those risks.
  • Waiver and Release: You will not hold NinjaOne responsible for any adverse or unintended consequences resulting from your use of the script, and you waive any legal or equitable rights or remedies you may have against NinjaOne relating to your use of the script.
  • EULA: If you are a NinjaOne customer, your use of the script is subject to the End User License Agreement applicable to you (EULA).