How do I disable/enable a USB drive?

Page 1 of 2 12 LastLast

  1. Posts : 1,596
    X
       #1

    How do I disable/enable a USB drive?


    I have a WD Elements drive on a Windows 10 desktop. It's 8 TB in a USB-connected enclosure.

    I want to take it offline when I need to.

    I could just unplug it ... but that's inconvenient.
    I'd prefer to either (a) power it down with a software command, or (b) "unmount" it (to use Linux terminology).
    And I'd like to be able to do the reverse, when needed.

    But I don't know how to do any of that.
      My Computer


  2. Posts : 9,118
    Mac OS Catalina
       #2
      My Computer


  3. Posts : 17,280
    Win 10 Pro 64-bit v1909 - Build 18363 Custom ISO Install
       #3

    Hello @margrave55,

    You could probably achieve this using a Script with Diskpart commands, but that would probably involve hard coding specific parameters. I did a bit of investigating for you and found this which might be useful . . .

    > 5 Ways to Remount Ejected or Safely Removed USB Device Without Unplug and Reinsert

    Additionally, from what I have read, it might also depend on whether or NOT it is powered by AC/DC.

    I hope this helps.
      My Computer


  4. Posts : 1,596
    X
    Thread Starter
       #4

    Thanks ...
    BTW ... this is the G: drive.

    So I tried that, but it says that the device is currently in use.

    Lock Hunter says that the device is locked by:
    1. System
    2. svchost.exe (Service: TrkWks)
    C:\WINDOWS\System32\svchost.exe -k LocalSystemNetworkRestricted -p -s TrkWks

    Lock Hunter has an Unlock It button.
    When I click it it "kills" that #2 item, but not #1.
    And I can still access G: drive.

    But if I then do the "safely remove hardware" thing, the G: drive is gone.

    So that works ... but it's not suitable for me because:
    1. I now have to unplug and re-plug that drive to bring it back.
    2. This is a manual process. I'd like to accomplish this with a command or script.
      My Computer


  5. Posts : 13,797
    Windows 10 Home x64 Version 22H2 Build 19045.2364
       #5
      My Computer


  6. Posts : 1,365
    Windows 10 Pro (+ Windows 10 Home VMs for testing)
       #6

    Try Nir Sofer's USBDeview.

    It has commandline arguments to enable/disable by name, serial no., PID/VID, etc.

    Hope this helps...
      My Computer


  7. Posts : 13,060
    Win10 Version 21H2 Pro and Home, Win11 Pro and Home
       #7

    The only problem I have with USB devices being disabled rather that unplugged is that the OS no longer knows about them, haven't found a better way than physically replugging that works on whatever computer I'm working on.
      My Computers


  8. Posts : 13,797
    Windows 10 Home x64 Version 22H2 Build 19045.2364
       #8

    I agree with RickC. NirSoft USBDeview is also a good method. I imagine that it would also require less study & effort than the DevCon methods I posted about earlier.
    Disable-enable USB device from command-line on Windows - NirSoft


    Best of luck,
    Denis
      My Computer


  9. Posts : 1,596
    X
    Thread Starter
       #9

    I tried Nir Sofer's USBDeview.

    I used it to "disable" the WD Elements 25A3 USB Device ... and it says that it's now disabled.
    But I'm still able to access it, as usual.

    So no luck with that tool.
      My Computer


  10. Posts : 13,797
    Windows 10 Home x64 Version 22H2 Build 19045.2364
       #10

    I just tried the NirSoft USBDeview tool and it worked.

    I checked these before starting, after disabling & again after re-enabling the USB stick:
    File explorer - check access to the drive then select a different drive to make sure the test drive was left free before issuing any commands that affected it. Similarly, I closed all applications that might access it.
    Device mgr - check it is shown [as normal device when enabled & hidden device when disabled]
    Registry entry - accessed by right-clicking on its InstanceID cell in the USBDeview results table & selecting Open in RegEdit

    1.1 I ran USBDeview to get the InstanceID, which was USB\VID_05DC&PID_A81D\AA5Y3C390RITMT0N
    1.2 I tested it before starting:
    File explorer - The drive was shown and I had access to it. I then selected a different drive to make sure the test drive was free.
    Device manager - The USB stick appeared as a 'normal' device
    Registry - The "ConfigFlags" entry was 00000000


    2.1 In an elevated cmd window, I ran this cmd (C:\Tools\External\NirSoft\USBDeview is where I happen to keep this tool stored)
    Code:
    C:\Tools\External\NirSoft\USBDeview\USBDeview.exe /disable "USB\VID_05DC&PID_A81D\AA5Y3C390RITMT0N"
    2.2 I tested it whilst disabled:
    File explorer - The drive was no longer shown so no access was possible
    Device manager - The USB stick now only appeared as a Hidden device { as expected}
    Registry - The "ConfigFlags" entry had changed to 00000001


    3 In an elevated cmd window, I ran this cmd (C:\Tools\External\NirSoft\USBDeview is where I happen to keep this tool stored)
    Code:
    C:\Tools\External\NirSoft\USBDeview\USBDeview.exe /enable "USB\VID_05DC&PID_A81D\AA5Y3C390RITMT0N"
    3.1 I tested it again after re-enabling it:
    File explorer - The drive was once again shown and I had access to it
    Device manager - The USB stick once again appeared as a 'normal' device
    Registry - The "ConfigFlags" entry had changed back to 00000000



    Is it possible that you accidentally ran the command in a non-elevated command prompt window? No, that doesn't fit with your comment about seeing it was "disabled" ["it says that it's now disabled" - you did not mention where you saw this entry i.e. what "it" was.]


    Is it possible that you had the device selected in File explorer or another application before you started and that state preserved your access to it [which would indicate that the disabling procedure requires free access to the device to properly disable it]?



    All the best,
    Denis
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd
All times are GMT -5. The time now is 01:48.
Find Us




Windows 10 Forums