16

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.

John Gardeniers
  • 27,262
  • 12
  • 53
  • 108

6 Answers6

3

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.

Christopher_G_Lewis
  • 3,647
  • 21
  • 27
3

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 :)

kolypto
  • 10,738
  • 12
  • 51
  • 66
2

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.

Nixphoe
  • 4,524
  • 7
  • 32
  • 51
Alpha
  • 21
  • 1
  • 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 06:43
2

I just tested this out and was able to verify this works in Windows Vista and also verified it works in Windows 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 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.

Peter Mortensen
  • 2,319
  • 5
  • 23
  • 24
DHayes
  • 351
  • 2
  • 10
1

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 readd it by going to Device Manager, right clicking on the computer object and click scan for new hardware.

Peter Mortensen
  • 2,319
  • 5
  • 23
  • 24
William Hilsum
  • 3,506
  • 5
  • 28
  • 39
0

Try Microsoft's devcon command line utility.

Peter Mortensen
  • 2,319
  • 5
  • 23
  • 24
NoahD
  • 407
  • 5
  • 10