Is there a commandline "dismount" command for USB external drives?

A

Al Dykes

I want to script an xcopy command and then dismount the USB drive. Is
there a hack to do this?

I expect the "mount" will be automatic when I physically unplug and
then replug the drive.

One of these days, Windows will be "finished".

Thanks
 
P

Pegasus \(MVP\)

Al Dykes said:
I want to script an xcopy command and then dismount the USB drive. Is
there a hack to do this?

I expect the "mount" will be automatic when I physically unplug and
then replug the drive.

One of these days, Windows will be "finished".

Thanks

deveject.exe works very nicely. You can get it from here:

http://www.heise.de/ct/03/25/links/206.shtml

You could also use devcon.exe from the Windows Resource
Kit to disable the USB device. However, you will then have
to re-enable it before using it.
 
U

Uwe Sieber

P

Pegasus \(MVP\)

Uwe Sieber said:
This tool (c't deveject) works with drives only that have
a drive type DRIVE_REMOVABLE. The are some USB flash drives
and lots of USB hard drives that have DRIVE_FIXED.

And it is written for Windows 2000. Under XP it reports
always success even when it failed because Microsoft has
changed the API.

My tool works better in most cases :)
http://www.uwe-sieber.de/files/removedrive.zip


Greetings from Germany

Uwe

This sounds interesting. I put it to the test by doing this:

1. Determine the name of the USB device I wish to
disconnect, using the "Safe Removal dialog". It is
"USB Mass Storage Device".

2. Attempt to disconnect it with this command:
deveject -EjectName:"USB Mass Storage Device"
DevEject 1.0 2003 c't/Matthias Withopf
Ejecting 'USB Mass Storage Device'
[USB\VID_10D6&PID_1000\5&1719D762&0&1]...ok.
1 device(s) ejected.

3. Unplug the USB device, plug it back in again, ensure
that Windows recognises it.

4. Attempt to disconnect it with this command:
removedrive "USB Mass Storage Device"
RemoveDrive V0.8 - removes removable drives
Freeware by Uwe Sieber - www.uwe-sieber.de
Removing Device 'USB Mass Storage Device'Device not found!
failed

Either removedrive.exe has some teething problems or
my WinXP Professional installation is one of those cases
where deveject.exe works better than removedrive.exe.
 
U

Uwe Sieber

1. Determine the name of the USB device I wish to
disconnect, using the "Safe Removal dialog". It is
"USB Mass Storage Device".

"USB Mass Storage Device" is the device class, not the
device name. c't deveject looks for device classes too.
Using "USB Mass Storage Device" would remove all you
USB drives.

I've seen no use for removing all USB drives.
RemoveDrive works with drive letters, other mount points
and device names only.

You are right. This is one case where c't deveject is
better :)


Greetings from Germany

Uwe
 
P

Pegasus \(MVP\)

Uwe Sieber said:
"USB Mass Storage Device" is the device class, not the
device name. c't deveject looks for device classes too.
Using "USB Mass Storage Device" would remove all you
USB drives.

I've seen no use for removing all USB drives.
RemoveDrive works with drive letters, other mount points
and device names only.

You are right. This is one case where c't deveject is
better :)


Greetings from Germany

Uwe

I tried "removedrive G:", and this time it worked. I shall
now try the command in a few different environments.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top