 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
leonix
Joined: 28 Jan 2005 Posts: 2
|
Posted: Fri Jan 28, 2005 4:44 pm Post subject: umount USB stick (deveject) [CMD] |
|
|
deveject unmounts ("eject") your usb mass-storage device
ftp://ftp.heise.de/pub/ct/listings/0316-208.zip
It is a win32 console application and includes the source-code.
I would be happy if it can be included into autohotkey as command.
(to omit the ugly black cmd-window).
Leo. |
|
| Back to top |
|
 |
BoBo Guest
|
Posted: Fri Jan 28, 2005 5:08 pm Post subject: |
|
|
@ leonix
Junge, Junge, (boy oh boy)
you're in BIG trouble now
1) if its a recommandation it would belong to the Forums Utilities Section
2) if you request to implement it within AHK it belongs to the Forums Wish Section
3) if you agree on both of the above, will prevent you from going directly to Jail
@ Chris
have I requested a Jail Section so far ?  |
|
| Back to top |
|
 |
BoBo Guest
|
Posted: Fri Jan 28, 2005 5:19 pm Post subject: |
|
|
| Quote: | | (to omit the ugly black cmd-window). |
@ leonix
Check this out:
| Quote: | RunWait, %COMSPEC% /C ECHO Es lebe die DOS Box > leo.txt,, Hide
MsgBox, 0, Greetings from an ugly DOS box, Yes there was a ugly black cmd window!`nbut you havn't seen it!`nCause it was hidden.`nBye., 3
Run, notepad %A_WorkingDir%\leo.tx,, Max
WinWaitClose, leo.txt - Notepad
FileDelete, leo.txt |
OK, now let's go back and RTFM  |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10450
|
Posted: Fri Jan 28, 2005 5:30 pm Post subject: Re: umount USB stick (deveject) [CMD] |
|
|
| leonix wrote: | deveject unmounts ("eject") your usb mass-storage device
I would be happy if it can be included into autohotkey as command.
(to omit the ugly black cmd-window). | I will add it to the to-do list. Thanks.
I've moved this topic to the Utilities forum since others might find this tool useful. |
|
| Back to top |
|
 |
BoBo Guest
|
Posted: Fri Jan 28, 2005 5:39 pm Post subject: |
|
|
@ leonix
Thx for sharing it. Looks quite usefull.  |
|
| Back to top |
|
 |
Babis
Joined: 08 Dec 2005 Posts: 45
|
Posted: Thu Dec 29, 2005 1:01 pm Post subject: |
|
|
| I know that this is almost a year old, but as I was searching how to umount my USB flash disk, I found it, but it does not working. I am wondering if there is another way to do it. |
|
| Back to top |
|
 |
not-logged-in-daonlyfreez Guest
|
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 5298
|
Posted: Wed Aug 29, 2007 6:31 pm Post subject: |
|
|
A wrapper for DevEject.exe to Eject USB Drives:
| Code: | Msgbox, % DevEject("J:")
DevEject( Drive="" ) {
IfNotExist, %Drive%\, Return 4
IfNotExist, DevEject.exe, Return -1
RunWait, DevEject.exe -EjectDrive:%Drive%,, Hide UseErrorLevel
Err := ErrorLevel
DriveGet, Status, Status, %Drive%
Return ( Status="Invalid" ) ? 0 : ( Err=0 ) ? 16 : Err
} |
Returns an errorcode of 0 if the drive is ejected successfully.
There is a native way of ejecting drives ( also given in AHK Doc ) : Eject any drive by Thalon
One advantage of DevEject is that it powers down the device which is as good as working from "Safely Remove Hardware" icon available on Tray. This means the drive is no longer listed in explorer windows and other file/folder dialogs though the drive may still be left unplugged.
On a related note: To programmatically activate the "Safely Remove Hardware" dialog from a script, use:
| Code: | | Run, %A_WinDir%\System32\rundll32.exe shell32.dll`,Control_RunDLL hotplug.dll |
Download:
DevEject.exe [ 45 KB ]
DevEject.cpp [ 25 KB ]

Last edited by SKAN on Fri Dec 28, 2007 5:02 pm; edited 1 time in total |
|
| Back to top |
|
 |
Guest
|
Posted: Sat Dec 08, 2007 6:24 pm Post subject: |
|
|
any ideas why deveject doesnt work with my Western Digital Passport 60gb ? i can eject my kingston usb stick just fine
gives me error:
10
? |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 5298
|
Posted: Sat Dec 08, 2007 6:31 pm Post subject: |
|
|
| Anonymous wrote: | gives me error:
10
? |
From CPP file I can see
| Code: | | deec_ErrorGettingDeviceId = 10 |
You may try using the Device ID directly to eject it.
 |
|
| Back to top |
|
 |
corrupt
Joined: 29 Dec 2004 Posts: 2328
|
Posted: Sun Dec 09, 2007 1:44 am Post subject: |
|
|
| out of curiosity... why not just left click the icon in the system tray once (note: not right click or double click - left click once), choose the device you want to eject from the small menu that appears by left clicking once to stop and eject the device? It's a built-in feature that works quite well in most cases... |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 5298
|
Posted: Sun Dec 09, 2007 1:58 am Post subject: |
|
|
It is harder when you keep plugging in and out various USB devices.
BTW, I never knew of this single click. Thanks. I will use the tip for my laptop.
 |
|
| Back to top |
|
 |
Guest
|
Posted: Sun Dec 09, 2007 2:06 pm Post subject: |
|
|
@Skan
i got the script that gives me the device serial but how do you mean i should use it with your wrapper? |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 5298
|
Posted: Sun Dec 09, 2007 2:55 pm Post subject: |
|
|
| Anonymous wrote: | | i got the script that gives me the device serial but how do you mean i should use it with your wrapper? |
You have to use it directly with DevEject.exe !
The problem with DevEject.exe is that it returns 0 for
successful ejection as well when the device is in use. That is why the need to wrap it into a function.
So I test it like follows:
Run DevEject and capture its errorcode
Check the Drive Status to see whether it is still there
If drive is not there, fine, return 0
if not
{
if errorlevel is zero, not fine, return undefined errorlevel of 16
or else return deveject errorlevel itself
}
The above is what the last line does:
| Code: | | Return ( Status="Invalid" ) ? 0 : ( Err=0 ) ? 16 : Err |
Hope you can adapt this to your needs. |
|
| Back to top |
|
 |
Guest
|
Posted: Fri Dec 28, 2007 3:15 pm Post subject: |
|
|
whats wrong with this code, i get nothing?
Driveletter might change so i want to use the serial
| Code: | Msgbox, % DevEject(%kingston%:)
SetFormat, Integer, H
DriveGet, DrvList, List, REMOVABLE
Loop, Parse, DrvList
{ DriveGet, DrvSerial, Serial, %A_Loopfield%:
StringTrimLeft, DrvSerial, DrvSerial,2
StringUpper, DrvSerial, DrvSerial
if( %DrvSerial% = 7CFK5E15 ){
%A_Loopfield% := kingston
}
}
DevEject( Drive="" ) {
IfNotExist, %Drive%\, Return 4
IfNotExist, DevEject.exe, Return -1
RunWait, DevEject.exe -EjectDrive:%Drive%,, Hide UseErrorLevel
Err := ErrorLevel
DriveGet, Status, Status, %Drive%
Return ( Status="Invalid" ) ? 0 : ( Err=0 ) ? 16 : Err
} |
|
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|