I thought I knew DOS pretty well, but I had to go back a browse a MS-DOS command list to refresh my memory.
When I was good at DOS, we didn't have USB drives.
I run a backup job, using RoboCopy, from a simple batch file and would love to know if anyone has found a built-in command that will effectively force writing of all directory information once the RoboCopy job is ended.
A search of the web serves up several utility programs, but I am hoping to use native Windows XP stuff so that the batch file is transportable.
DOS command-line to eject a USB drive
-
- PlutoniumLounger
- Posts: 15613
- Joined: 24 Jan 2010, 23:23
- Location: brings.slot.perky
DOS command-line to eject a USB drive
There's nothing heavier than an empty water bottle
-
- Administrator
- Posts: 78463
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: DOS command-line to eject a USB drive
It looks like you'll need a utility such as The DevCon command-line utility from Microsoft (free).
You can invoke the "Safely remove hardware" dialog using hotplug.dll and you can do a low-level eject using mountvol.exe but that bypasses the device manager - not a good idea.
You can invoke the "Safely remove hardware" dialog using hotplug.dll and you can do a low-level eject using mountvol.exe but that bypasses the device manager - not a good idea.
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 5408
- Joined: 24 Jan 2010, 08:33
- Location: A cathedral city in England
Re: DOS command-line to eject a USB drive
I'd second Hans in the use of DevCon* for that function, not that I've used it much. I suspect it has all the same problems as the clicking on the green icon on the system tray, when it says "the device can't be stopped right now" (or near offer)...
I think the full 'hotplug.dll' command line is:
Rundll32.exe shell32.dll,Control_RunDLL hotplug.dll
What *I* want is a built-in command to physically eject a CD/DVD or open the CD/DVD tray, after have written an ISO file to the optical disk!
* Later...
I really like the description of DevCon's 'findall' subcommand:
"find devices including those which are not present"
(my italics)!
I think the full 'hotplug.dll' command line is:
Rundll32.exe shell32.dll,Control_RunDLL hotplug.dll
What *I* want is a built-in command to physically eject a CD/DVD or open the CD/DVD tray, after have written an ISO file to the optical disk!
* Later...
I really like the description of DevCon's 'findall' subcommand:
"find devices including those which are not present"
(my italics)!
John Gray
"(or one of the team)" - how your appointment letter indicates you won't be seeing the Consultant...
"(or one of the team)" - how your appointment letter indicates you won't be seeing the Consultant...
-
- PlutoniumLounger
- Posts: 15613
- Joined: 24 Jan 2010, 23:23
- Location: brings.slot.perky
Re: DOS command-line to eject a USB drive
It seems to deliver a history of every USB device that ever has been plugged in since the last FORMAT C:/ Command!John Gray wrote:I really like the description of DevCon's 'findall' subcommand:
"find devices including those which are not present"
(my italics)!
There's nothing heavier than an empty water bottle
-
- PlutoniumLounger
- Posts: 15613
- Joined: 24 Jan 2010, 23:23
- Location: brings.slot.perky
Re: DOS command-line to eject a USB drive
OK. Thanks but ...HansV wrote:It looks like you'll need a utility such as The DevCon command-line utility from Microsoft (free).
I allotted my customary 30 minutes to try to comprehend/get it working and failed.
(I figure that 30 minutes is more than enough time to learn how to do a simple task)
The output from devcon is voluminous and confusing (333 devices to wade through in an awful format)
I webbed a bit more and found USB Disk Eject 1.2 Beta 4 – Last Beta Before Release (Hopefully), crossed my fingers and installed it, and ran a command line
Code: Select all
usbd /removeletter g:
That's good enough for me. For now.
More detail: The drive is TrueCrypted, although it was NOT mounted by trueCrypt, so to Windows it always looks like an unformatted drive.
When I turn the power on, drive G: re-appears as an unformatted drive, so - touch wood - all appears to function as it should.
I fired up TrueCrypt, mounted and explored the drive; all appears well.
This is a simple interface and does what I want it to do.
There's nothing heavier than an empty water bottle
-
- Administrator
- Posts: 78463
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: DOS command-line to eject a USB drive
Devcon is the command-line equivalent of the Device Manager, which is very powerful but indeed confusing. For just ejecting a USB drive it's overkill. I'm glad you found a dedicated utility that's easy to use.
Best wishes,
Hans
Hans
-
- PlutoniumLounger
- Posts: 15613
- Joined: 24 Jan 2010, 23:23
- Location: brings.slot.perky
Re: DOS command-line to eject a USB drive
Yes. bgbennyboy has effectively waded through the morass and saved a whole bunch of us hours of time (and frustration)HansV wrote:Devcon is the command-line equivalent of the Device Manager, which is very powerful but indeed confusing. For just ejecting a USB drive it's overkill. I'm glad you found a dedicated utility that's easy to use.
There's nothing heavier than an empty water bottle