USB Drives Disabled

This topic contains 0 replies, has 1 voice, and was last updated by Profile photo of Forums Archives Forums Archives 5 years, 5 months ago.

  • Author
    Posts
  • #6451

    by cswan at 2013-02-27 23:13:00

    I am working on a project which in part will automate copying files from multiple SD memory cards to a hard drive. I was trying to find a way to use powershell to dismount/eject USB cards automatically for the user before he physically loads the next card. From the web, I copied and ran the following code which I thought would dismount the selected drive:

    $vol = get-wmiobject -Class Win32_Volume | where{$_.Name -eq 'G:\'}
    $vol.DriveLetter = $null
    $vol.Put()
    $vol.Dismount($false, $false)

    The drive along with all USB mass storage devices was removed and I have been unable to restore the USB mass storage devices. I am running Windows 7 and have rebooted, uninstalled the USB drivers and allowed the system to re-install. The USB ports function normally for other USB devices. The Device Manager – Portable Devices – WPD FileSystem Volume Driver – General tab/Device status "This device cannot start (Code 10)". I need 2 things – First and foremost to reverse the original code and restore use of the USB mass storage. Second, if possible – a way to eject USB cards so that another card can be re-installed immediately after removal. Thank you so much for any help you can offer.

    by DonJ at 2013-02-28 09:19:57

    Sounds like the mass storage profile drivers got unbound ;). The Dismount() method shouldn't have done that, though, and without knowing what DID happen, I don't have any suggestions for restoring functionality. You may end up having to do some serious OS-level repair. I suspect something went wrong with the Dismount() method. Not sure why DriveLetter would be set to $null... I've never done that. Anyway... fixing the problem is unfortunately a bit beyond the scope of PowerShell Q&A, but we'll see if anyone else has any helpful suggestions for you!

    In terms of doing this normally, I've always relied on the mountvol command. http://www.tek-tips.com/viewthread.cfm?qid=1701578 offers some other techniques I've seen people use in the past. There's also a technique at http://portableapps.com/node/639#comment-2238 that some of my customers use. All are adaptable to PowerShell.

    by cswan at 2013-02-28 11:37:24

    Problem Resolved. Used 'USB Safely Remove' (shareware) utility to re-establish original drive name.

You must be logged in to reply to this topic.