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

Tech-Archive recommends: Fix windows errors by optimizing your registry



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"

.



Relevant Pages

  • how do i remove a usb drive with a script?
    ... I wrote a customer a batch script that backs up her ... internal hard drive to an external USB hard drive. ... going into the device manager and doing a remove ... I know that there is a way to do this with "devcon" from ...
    (microsoft.public.win2000.registry)
  • Re: VBScript,Getting the Managers Display Name
    ... I ran the script and it pulled ... the data but would not display the Manager when running it. ... I also added steps to close the spreadsheet and quit ... Set objRange = objExcel.Selection.EntireColumn ...
    (microsoft.public.windows.server.scripting)
  • Problems after new install
    ... which shows that Win 2000 is not responding. ... If I choose Shutdown from task manager, ... "Internet Explorer Script Error. ... that are initiated at startup (using StartUp Cop), ...
    (microsoft.public.win2000.general)
  • New installation problems.
    ... which shows that Win 2000 is not responding. ... If I choose Shutdown from task manager, ... "Internet Explorer Script Error. ... that are initiated at startup (using StartUp Cop), ...
    (microsoft.public.win2000.setup)
  • Re: running a vbs script
    ... When you do write a script to remove "Windows Manager" from the taskbar ... still present as a working toolbar in the taskbar. ...
    (microsoft.public.windowsxp.general)