Re: how do i remove a usb drive with a script?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



On Mar 23, 1:50 am, Michael Bednarek
<mbATmbednarek....@xxxxxxxxxxxxxxxxx> wrote:
On 22 Mar 2007 15:09:58 -0700, ToddAndMargo@... wrote in
microsoft.public.win2000.registry:



I know this may not be the correct group to post this in,
but I figure you will all forgive me if it is not. ("devcon"
deals with the registry.)

I wrote a customer a batch script that backs up her
internal hard drive to an external USB hard drive.
Problem: she ALWAYS forgets to press the add/remove
icons and just jerks the cord out of the drive (she has three
drives that she rotates). I clear the error by
going into the device manager and doing a remove
on the external drive. (I fear showing her how to
use the device manager.)

Now, I know that there is a way to do this with "devcon" from
my script. Problem: I am not smart enough to figure out how.
Can some kind person tell me 1) the devcon command to
search for the external usb hard drive and 2) how to use
devcon the do the same thing I manually do in the device
manager?

AFAIK devcon allows you to disable a device, which has the effect that
it gets re-installed the next time it's seen. That's IMO not the
equivalent of "Safely Remove Hardware".

To bring up the GUI for "Safely Remove Hardware" from a script:
RUNDLL32.exe SHELL32.DLL,Control_RunDLL hotplug.dll

To actually remove/eject a device, I use:
deveject.exe -EjectDrive:E:
See <ftp://ftp.heise.de/pub/ct/listings/0316-208.zip>.
Note that parameters to deveject are case sensitive.

Further reading:
"DevEject Alternatives"
<http://portableapps.com/node/3160>
which i.a. points to:
<http://www.uwe-sieber.de/usbstick_e.html>.

--
Michael Bednarek http://mbednarek.com/ "POST NO BILLS"

I did not know deveject existed. Thank you!
-T

.



Relevant Pages

  • Re: removing usb device without administrator rights?
    ... "Michael Bednarek" wrote in message ... When DevEject is used, there is nothing to click, it's ... If I run the following command: ... batch file from a shared area without giving them too many access rights. ...
    (microsoft.public.win2000.general)
  • Re: Mounting/Unmounting USB
    ... DevEject 1.0 2003 c't/Matthias Withopf: ... Michael Bednarek http://mbednarek.com/ "POST NO BILLS" ...
    (microsoft.public.scripting.vbscript)