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.
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:
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.
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 :)
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.
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.
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.
Try Microsoft's devcon command line utility.