This is a simple eject script made with AutoIT. LINK UPDATED 31th May
It searches for processes running from the USB drive and closes them gracefully - That is unsaved open files will prompt for saving - only caveats are if an app minimises to the tray when closed as in UTorrent (behaviour can be changed in the app) and USB Files opened with programs that are not on the USB drive will not close if they do not have the path in their child window title.
I downloaded it, it is only an eject.exe and an eject.au3...
Do you have some documentation? how it works? it also uses command lines? where is the source code? do I need to have *.au3 file in my portable (not U3)?
Please provide source code, a readme, and a license... I'm specially interested in the readme file... and this forum wants the code and the license...
Thanks in advance for your answers and for your work.
------------------
I don't have a signature
Should I have a signature?
If a packet hits a pocket on a socket on a port,
and the bus is interrupted as a very last resort,
and the address of the memory makes your floppy disk abort,
then the socket packet pocket has an error to report
The source is the au3 file - It is AutoIT script The exe is just compiled and can be decompiled using AutoIT
It works by searching Windows processes for any PID with a path matching /PortableApps/. It then uses an AutoIT function WinClose() to close these Windows.
I have just uploaded an update as the original closed the script before it closed other paths .. Doh!
I am just experimenting with AutoIT scripting, its all very new to me - Just made one that sets a Windows Environment Variable for the USB drive letter.
Just have to "run on exit PStart" and eject.exe will close any app running... don't have to say which app?
Then I have another question... convey have -exit, and I'm using it... it affect it?
------------------
I don't have a signature
Should I have a signature?
If a packet hits a pocket on a socket on a port,
and the bus is interrupted as a very last resort,
and the address of the memory makes your floppy disk abort,
then the socket packet pocket has an error to report
That's the idea - Any apps that minimise when closed (like utorrent) might just minimise. You can usually change that behaviour within that apps settings.
It will work from anywhere on your pen drive
Convey shouldn't affect it
Cool! ...last question...
It quit/exit/close not kill, right?
EDIT: and then it closes itself and eject the drive?
------------------
I don't have a signature
Should I have a signature?
If a packet hits a pocket on a socket on a port,
and the bus is interrupted as a very last resort,
and the address of the memory makes your floppy disk abort,
then the socket packet pocket has an error to report
It closes files gracefully - So if a file is open it will automatically prompt a dialogue box to save or not. The script closes after you click OK on the message box at the end.
One suggestion: Do not close processes running from the path '/PortableApps/'. Close these on the drive you're running from. It's not only more universal - it's also safe with multiple devices connected.
ADDED:
One more:
change
StringInStr($path, "Eject")
to something like (I don't know AI3 )
StringInStr($path, "\\Eject.exe")
or add a safe method of doing it."Those people who think they know everything are a great annoyance to those of us who do." Asimov
StringInStr($path, "Eject")
The above line is just to stop the script closing itself. It only parses to the function if it is false.
I have made the following changes and updated the link.
Closes all processes from the USB drive letter where ..
The drive letter is discovered by finding the PortableApps window and extracting its path. Therefore PAM must be running.
If anyone know how to discover the path of open child windows that would be useful ...
StringInStr($path, "Eject")
The above line is just to stop the script closing itself. It only parses to the function if it is false.
I know. But there may be another open prog with "Eject" somewhere in it's path. That's why I suggest to specify the detect string as precisely as possible or (better) find own path and compare others with it.
"Those people who think they know everything are a great annoyance to those of us who do." Asimov
OK i got you - Try the new link. I've used a macro for the script path and compare it to the path
If StringInStr($var[$i][0], $driveLetter) AND $path @AutoItExe Then
Thanks for that.
Instead of passing the window title to _WinGetPath pass the HWND. ($var[$i][1])
cowsay Moo
cowthink 'Dude, why are you staring at me.'
Now you're in unknown territory for me. That appears to be a Hex identified? What difference will that make?
You basically replace
$path = _WinGetPath($var[$i][0])
with$path = _WinGetPath($var[$i][1])
. That will make it so that you will get the right window if there are two matches.cowsay Moo
cowthink 'Dude, why are you staring at me.'
OK i see now - That's done and link updated - Cheers
Do you know how this script could find the path of child windows? I am not sure if the SQL in the function retrieves this infor or not.
For example an image/file on the pen drive opened by a program on from C:\
Sorry, I don't know how do that.
Another tip: replace the two
WinClose($var[$i][0])
calls withWinClose($var[$i][1])
.cowsay Moo
cowthink 'Dude, why are you staring at me.'
As you've got your path, wouldn't it be better to remove looking for PAM to get the drive letter and use yours instead?
"Those people who think they know everything are a great annoyance to those of us who do." Asimov
Yes definately... Updated link
I tried, first whit zz eject.exe located in /portableapps/otros/, then moved to /portableapps/, and now in root directory... it shows a message saying "close any exit dialog boxes - device is safe to remove", but...
It kills (not close) convey... it closes stickies, but pStart, nPOP and KeePass remains open, and of course USB drive don't eject.
------------------
I don't have a signature
Should I have a signature?
If a packet hits a pocket on a socket on a port,
and the bus is interrupted as a very last resort,
and the address of the memory makes your floppy disk abort,
then the socket packet pocket has an error to report
KeePass and PStart are not closed. If I manually close all apps prior to executing, the drive isn't ejected.
@MISIIM Thanks done
Convey closes OK for me, I do not run PStart or Keypass so please try the latest upload and test again.
This is not a perfect Eject script, I am working on its limitations so testing helps... but my main objective is to learn AutoIT scripting
I figured out part of the problem. Using Process Explorer I see that
PStart.exe command line is \PortableApps\PStart\PStart.exe
KeepassPortable.exe shows no command line
KeePass.exe command line is "V:\PortableApps\KeePassPortable\App\keepass\keepass.exe"
It appears that eject can't match Pstart and KeePassPortable but I'm not sure why KeePass.exe itself isn't ended.
Other portablexxxx.exe that I looked at all start with v:\portableapps\xxxx as do the corresponding applications.
Do these apps close normally or do you have to right click a menu to exit them? Any apps that minimise instead of closing as their default behaviour will not close with this script.
I may be able to search these out and brute force kill their processes.
both normally reside in the tray.
Using XP's taskkill command I can close keepass.exe without using the /f parameter. It works whether or not it's minimized to the tray.
With PStart I have to add the /f parameter to force it to close.
Try the new file I put in the zip file.
It uses processclose for keepass.exe and pstart.exe
I don't like this idea.
Can't you just check executable path instead of command line?
It would also work faster.
BTW did you try Eject on limited user account? Getting command line of some (possibly all..) processes may fail. With highly limited privileges (i.e. admin may set they low for apps that are not run from Program Files) it definitely will.
"Those people who think they know everything are a great annoyance to those of us who do." Asimov
I agree, was a quick fix... If those two apps have command line exit switches I could use those instead. Do they?
In fact I just received an answer from nPOP telling me that they are going to add it (-exit) to the new release...
Convey closes by itself (-exit)
KeePass don't close and stickies don't close... with eject.
Both nPOP, KeePass, and stickies are minimized when pressing close, both three needs right click -> exit.
Since my last post I started using NirCmd (search in this forum) to close running apps, and tried RemoveDrive (search this forum) to eject but it doesn't work either.
------------------
I don't have a signature
Should I have a signature?
If a packet hits a pocket on a socket on a port,
and the bus is interrupted as a very last resort,
and the address of the memory makes your floppy disk abort,
then the socket packet pocket has an error to report
Check the settings for Keepass and other apps as they sometimes give you the option to uncheck 'Minimize to tray on close'
Check the settings for Keepass and other apps as they sometimes give you the option to uncheck 'Minimize to tray on close'
the minimize to close in Keepass. As long as the keepass window is open Eject works on keepass but not pstart. Eject with kill does kill pstart but still doesn't kill keepass when it's minimized to the tray.
That got me thinking. I can set pstart to run regular eject when pstart closes. That solves the pstart problem but not keepass
An automatic eject at the end this would be great.
As @m2 says this is not a great solution and I am near my knowledge limit on this, though I am searching the AutoIT forums. What I want most for tis script at the moment is the ability to detect child windows (Files opened by external apps to the pen drive.) though I am not sure AutoIT can detect these.
App-specific solutions is an endless work - there are hundreds if not thousands mobile apps around and new ones comming at least weekly.
Read http://support.microsoft.com/kb/176391 , it should solve the problem with termination instead of closing.
"Those people who think they know everything are a great annoyance to those of us who do." Asimov
You know the Armogohma Suites... (find out more by looking for the thread in the beta forums), I will give you credit.
Also this script helps me alot when using Papps. So thanx!
--
As all of ya should know Microsoft is the Evil Empire, and Windows (a.k.a. Winblows or Windoze) is their greatest general, so please make a difference and install Linux or Free BSD on yer Windows comp.
Feel free - Glad you like it
can i use it too? i am working on an app and i think that i may have figured out how to eject with a single .exe. it doesn't always work but i'm trying to figure that out. i will give you plenty of credit. and one more question, how do you find what the drive letter that you are on?
Free to all who want it
I made this change on the version of the eject script I use (along with a direct process kill for an annoying app I use that will not respond to any messages I send it)
Instead of bringing up a messagebox when I'm done I run the device removal dialog (works in XP and Vista)
_________________________
* programmer (noun) : a predominantly nocturnal creature fueled by either Caffeine or Sugar (Or Both).
Excellent I'll add it when I get a chance.