help what is the command that eject the usb drive [solved]

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
abc0502
Posts: 1007
Joined: 26 Oct 2011 22:38
Location: Egypt

help what is the command that eject the usb drive [solved]

#1 Post by abc0502 » 02 Dec 2011 22:48

Hi, i'm trying to make a batch file that work from a usb drive
the batch will close the running programs on the usb and then eject the usb
my problem in the eject part ... what is the command for ejecting the usb drive.
i searched and many say there is no command but then how the windows eject the device then?
help please
Last edited by abc0502 on 12 Mar 2012 00:33, edited 1 time in total.

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: help what is the command that eject the usb drive

#2 Post by Ed Dyreen » 03 Dec 2011 09:05

'
Eject ? On a USB ?, you mean safely remove, dunno but you may want to disable it
( same effect as safe remove, flushes all buffers to disk ).
You can use DevCon, available from http://www.ed-dyreen.com/eDOS%20beta%20 ... 7.11.2011/
Find the device for your class which is 'USB: USB-controllers' and disable the device.
something like:

Code: Select all

@echo off
DevCon.EXE /?
DevCon.EXE classes
DevCon.EXE help FindAll
pause
exit 0

Code: Select all

for %%! in ( "USB"
) do (
   for /f "tokens=1* delims=: " %%A in ( 'DevCon.EXE FindAll ^=%%~! ^|findstr /i /c:":"'
   ) do (
      set "ID=%%A"
      set "DEVICE=%%B"
      set "HWID=!ID:~0,21!"
   )
)
"DevCon.EXE" disable !HWID!
You may want to try http://unattended.msfn.org/unattended.xp/ ( they also have a forum ).
You will find more information on those subjects there.

abc0502
Posts: 1007
Joined: 26 Oct 2011 22:38
Location: Egypt

Re: help what is the command that eject the usb drive

#3 Post by abc0502 » 04 Dec 2011 19:27

Thanks for the help :)

Post Reply