Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

From time to time I eject a USB device, generally a memory stick or external HDD, when I think I have finished transferring data only to realise there's something else I need to do with it. Normally this involves nothing more than unplugging the device and plugging it back in. What about if I'm doing the work from remote? Is there a command I can run that will have Windows re-detect and mount the device?

Update:

Thanks to all who responded.

Although some of the suggested methods will work they also cause problems if another device is connected via the same hub. Others, such as devcon, may well work for others but failed for me, although I don't know why not and won't be investigating it any further.

I would have preferred not to have to rely on a commercial product but Safelyremove, suggested in the accepted answer, worked so well in my tests I consider it a keeper.

share|improve this question
    
so you are "soft-ejecting" the USB device remotely? –  Jeff Atwood Jul 26 '09 at 5:30
    
Either by selecting "eject" from Explorer or using "safely remove..." in the system tray. I generally use the latter because the eject option is less than reliable. –  John Gardeniers Jul 26 '09 at 10:36

6 Answers 6

up vote 3 down vote accepted
+150

When you "safely remove" a USB HDD - it stops spinning. I believe there's a USB command to turn the device off (sleep mode, actually). So the thing you need is how to turn the device back on.

The application Safelyremove has a command-line tool that is capable of returning the device back: "Returning just stopped device back!".

It is shareware, but it works :)

share|improve this answer
    
superuser.com/questions/731404/… You saved my USB and my Laptop. –  Maria Meh Mar 20 at 14:34
    
@MariaMeh, hehe, good luck in your development! :) –  kolypto Mar 21 at 0:02

Have you tried Microsoft's devcon command line utility?

share|improve this answer
    
I've tried devcon but it hasn't worked on any of the machines I tested it on. –  John Gardeniers Jul 26 '09 at 4:14

I was also going to suggest devcon, however in addition, there are a few gui tricks you can use.

If you use eject instead of safely remove, it unmaps the drive and kills all open handles (and displays the popup saying it is safe to remove), however the device is still present. You can then go to device manager and disable followed by enable the flash drive, and it should remap itself.

I can not guarantee, but I assume the same should work for safely remove - however if it does actually remove the device, you should be able to re add it by going to device manager, right clicking on the computer object and click scan for new hardware.

share|improve this answer

I just tested this out and was able to verify this works in Vista and also verified it works in XP. Disabling and re-enabling the USB device directly did not reinitialize it. The steps below did.

After the device has been "safely removed" go into the device manager. Find the USB Mass Storage Device, right-click on it, and select uninstall. Next, one at at time, disable, and re-enable the USB Host controllers. Take your time with this step, as one of the controllers will reinitialize the USB device.

None of this required a reboot, so it should meet your needs. Ignore any prompts for a reboot.

share|improve this answer

When you've click the eject/safely remove, go into device manager (Control panel -> System -> Hardware Tab).

Under USB, you should see the device with a (!) icon. If you view the device, it will say something like:

Windows cannot use this hardware device because its been prepared for "safe removal".

Change the view of Device manager using the View Menu to "Devices by connection". Find the parent USB hub. Right click it and disable the hub, then right click and enable the hub.

share|improve this answer

command line mountvol or mount. type in mountvol in command prompt to see your options. it explains all of the options in there. then create a batch file. you can access the batch file from the remote desktop. be sure to enable permissions in remote desktop. Try it out.

share|improve this answer
    
I'll give you an upvote for the effort but in reality mountvol is not really viable. Because the target machine and USB port are variables I could have traveled to the remote location and just used the normal GUI method by the time I work out the absurdly cryptic command parameters required. This is an area where Windows could and should have had a simple command but the developers just got plain lazy. –  John Gardeniers Mar 24 '12 at 6:43

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.