1

I want to make an usb disk write protected, I have found doing this as a solution:

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\StorageDevicePolicies]
"WriteProtect"=dword:00000001

But this has 2 drawbacks for me:

  1. It doesn't work on a already mounted usb disk, if the mounting is prior to modifying the registry, it works though if I remove and add the disk or any other disk again.

  2. This works for all usb ports.

So, what I what is to:

  1. Make the usb disk write protected based on the serial number(which I get in a windows service) immediately after I get the device_arrival event in my windows service. I don't want to have to reinsert the usb stick for it to work.

  2. And could it be possible to restrict this behaviour for specific usb disks? I mean, If I have usb disk nr1 which I want to be write protected, and usb disk nr2 which I don't want to be write protected, could I mount them bothm on my pc at the same time with the desired write/read premssions?

By the way, I want to do this in C#, and I'm working on Windows 7.

Preet Sangha
  • 64,563
  • 18
  • 145
  • 216
AlexandruC
  • 3,527
  • 6
  • 51
  • 80

1 Answers1

0

Don't know how valid this is but could you force an eject and remount in software?

How to programmatically unplug & replug an arbitrary USB device?

Community
  • 1
  • 1
Preet Sangha
  • 64,563
  • 18
  • 145
  • 216