Link to home
Start Free TrialLog in
Avatar of HooKooDooKu
HooKooDooKu

asked on

Programatically Dismount and Remount USB Drives

Is there a way to programatically dismount and remount a USB drive on a Windows machine (as far back as Windows XP) without ever unplugging the device?

The idea is to block access to the USB drive from even the operation system until such time that a scheduled program needs access to it.

No one would have physical access to the computer, so it would be fine if the OS would still automatically mount a USB drive when it is plugged in so long as a command/program could be run to logically dismount the drive until such time that the scheduled task needs access to it.  (So a system that is defeated by simply unplugging and replugging the USB drive in would be fine).
ASKER CERTIFIED SOLUTION
Avatar of ZabagaR
ZabagaR
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of nobus
i use safelyRemove for this - not free, but easy, and works well:
 http://safelyremove.com/?pid=1
Avatar of HooKooDooKu
HooKooDooKu

ASKER

I've found a copy of the devcon program... and I've taken a few minutes to try it here in the office with a thumb drive... but so far it is not working and the screen behavior is different than the example.  Then again, the office machine is Windows 7 x64 and I don't think I've gotten the correct version of devcon for that OS.

That's ok, because my intended target is an old XP machine at home.  I just haven't gotten around to actually trying it at home yet... but from what I've seen regarding devcon, I think it is going to work there.

I'll report back when I manage to actually TRY it on the XP machine... thanks for the help.
safelyremove has a trial edition also  - so you can test it
devcon works great. I use it just to disable and re-enable hardware. if you have any usage questions just ask.
You use windows device manager find the hardware ID that devcon needs. Get properties of your usb, go to details tab, under property choose "hardware id". you use the value displayed to tell devcon what hardware to enable/disable.

There's a 64-bit and 32-bit one. http://support.microsoft.com/kb/311272

devcon disable <hardware_ID>
devcon enable <hardware_ID>

You can use the "asterisk" *  as  a wildcard in hardware_ID
DEVCON.EXE eventually worked on the XP machine.  However, it took a couple of hours to figure out exactly how to disable the one drive on one particular USB host controller... and get things organized so that the disable didn't require a reboot (i.e. depending upon the order you've used DEVCON ENABLE, DEVCON DISABLE, and DEVCON RESTART... you might or might not get a message indicating that a reboot is needed for the disable to take effect.  Obviously I don't want to have to reboot the machine each time I simply want to disable a drive)