You are here

Eject Script 0.4

40 posts / 0 new
Last post
xrxca
Offline
Last seen: 10 years 1 month ago
Joined: 2007-07-03 23:59
Eject Script 0.4

Script updated to allow ejecting Fixed drives by default, this was causing problems with some USB attached hard drives as the drives were reported as Fixed rather than Removable. (if you wish you can turn this off with by setting FIXEDOK to 0 in the INI file.)
Information and Download

Aciago
Aciago's picture
Offline
Last seen: 5 months 1 week ago
Joined: 2007-01-24 14:23
I don't

use fixed, just my USB PenDrive, and don't have any problem with 0.3... should I change to 0.4?

------------------
I have no signature again... Cry

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 Biggrin

xrxca
Offline
Last seen: 10 years 1 month ago
Joined: 2007-07-03 23:59
No Other Changes

No Other changes so no real need to switch unless your using a USB hard drive.
_________________________
* programmer (noun) : a predominantly nocturnal creature fueled by either Caffeine or Sugar (Or Both).

_________________________
* programmer (noun) : a predominantly nocturnal creature fueled by either Caffeine or Sugar (Or Both).

Zappa
Offline
Last seen: 12 years 3 months ago
Joined: 2007-06-27 15:14
Lacie

Works for my 2.5" Lacie 40G drive.

Thanx Z

paulm
Offline
Last seen: 14 years 7 months ago
Joined: 2006-09-16 23:33
perfect.

thanks so much for this.. had started trying to write this myself, with little success. thanks for sharing!!

Signature automatically removed for containing links

arqbrulo
arqbrulo's picture
Offline
Last seen: 4 years 1 month ago
Joined: 2006-08-10 16:38
Thanks

Yeah, thanks. I just could not get 0.3 to work for me, but this is working fine (as of now).

Just one thing, on the readme file, It says that ejectexe is to run a program BEFORE ejectscript, but on the INI it says that it will run at the end of ejectscript. Which one is it? Also, is there a way to run 2 different programs? Or close certain apps with commandline parameters? (ie. Convey Portable) Thanks.
---------------
"Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river." -- Cyril Connolly

"In three words I can sum up everything I've learned about life: it goes on." -- Robert Frost
"In three words I can sum up everything I've learned about life: baby ain't mine." -- Adam Holguin

xrxca
Offline
Last seen: 10 years 1 month ago
Joined: 2007-07-03 23:59
At the end

The eject exe is run at the end of the script, I'll have to checkthe readme.
As for more than one, I've thought about adding it, but the new version of the app menu I hope to release in a couple days has my priority at the moment and it will have better support for running things on exit with command line parameters.
_________________________
* programmer (noun) : a predominantly nocturnal creature fueled by either Caffeine or Sugar (Or Both).

_________________________
* programmer (noun) : a predominantly nocturnal creature fueled by either Caffeine or Sugar (Or Both).

Zappa
Offline
Last seen: 12 years 3 months ago
Joined: 2007-06-27 15:14
Bug

As reported ES 0.4 works fine for my Lacie 40G as long as 'StartPortableApps.exe' is run from the drive [autorun.inf, autorun.bat or even double click]. But when it is started from windows run dialog, the script does nothing else as showing the eject drive dialog. No window is closed, no program is killed, even PAM is still running.

ZAP

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sorry about my bad English, the English lessons where always late at afternoon Smile

xrxca
Offline
Last seen: 10 years 1 month ago
Joined: 2007-07-03 23:59
Odd

That's a pretty odd way of starting the script, is the ejectscript.exe your trying to run from the dialog located on the removeable drive? If not you'll have to add the Drive to the command line ie: ejectscript.exe G: otherwise it has no idea what drive to shut applications down for.
Or are you saying your running the portableappsmenu from the run dialog? I just tried this and the eject seemed happy.
_________________________
* programmer (noun) : a predominantly nocturnal creature fueled by either Caffeine or Sugar (Or Both).

_________________________
* programmer (noun) : a predominantly nocturnal creature fueled by either Caffeine or Sugar (Or Both).

Zappa
Offline
Last seen: 12 years 3 months ago
Joined: 2007-06-27 15:14
Maybe

it wasn't clear enough because of my bad English: When the 'StartPortableApps.exe' was started from windows run dialog (because the drive is already connected), and after that, when I do click the eject button on PAM, the script does nothing else as showing the eject drive dialog.
When 'StartPortableApps.exe' is run from the drive [autorun.inf, autorun.bat or even double click] everything works as it should.

ZAP

xrxca
Offline
Last seen: 10 years 1 month ago
Joined: 2007-07-03 23:59
Ha

You should see how I brutalize French. (No I'm not about to give examples, I get enough flack from the Quebecois programmers I work with occasionally)

This seems very odd, I just tried a Start|Run... J:\StartPortableApps.exe then opened a few of the programs. solved a sudoku puzzle (just so some time had passed) then hit the eject button everything closed down properly.

Are you running XP or Vista? (Or I suppose 2000 could be in there as well) I don't have a Bad * Vista machine handy at the moment I'll have to try it tomorrow.
_________________________
* vista (adj) : overhyped.
I getting tired of fighting with Vista printing, an XP machine we replaced earlier this year that has two shared deskjets off it seemed like a good choice to toss vista on so I could answer questions when they came, and test our custom software on, but it's been a nightmare, both printers are now hanging off a Linux machine and the XP users now get what they expect to get again.

_________________________
* programmer (noun) : a predominantly nocturnal creature fueled by either Caffeine or Sugar (Or Both).

Zappa
Offline
Last seen: 12 years 3 months ago
Joined: 2007-06-27 15:14
I don't have Vista too

- no reason for tears, I think - running XP Home/German Edition
- PAM is R21b
- Eject script is 0.4
- Drive letter is S:\

Need more nfo?

ZAP

xrxca
Offline
Last seen: 10 years 1 month ago
Joined: 2007-07-03 23:59
I can't duplicate this

I've tried everything I can think of, can you try modifying your EjectSCript.ini file and set ASKFIRST=1 and make sure the ASKFIRSTPROMPT value has 'X:' in it (by default it does)

; Prompt the user to before trying to close any applications (0/1)
ASKFIRST=1
; Timeout for the Ask First Prompt (Seconds)
ASKFIRSTTIMEOUT=10
; Default if the askfirst prompt times out (0/1) (1 = Yes, 0 = No)
ASKFIRSTDEFAULT=1
; Text to use for ASKFIRST
ASKFIRSTPROMPT=OK to try closing applications running on drive X:

Then when you eject it will pop up the message with the Secret replaced by the current drive, that way we can figure out what drive the script thinks it's running from. (and if it's even being run at all)
_________________________
* programmer (noun) : a predominantly nocturnal creature fueled by either Caffeine or Sugar (Or Both).

_________________________
* programmer (noun) : a predominantly nocturnal creature fueled by either Caffeine or Sugar (Or Both).

Zappa
Offline
Last seen: 12 years 3 months ago
Joined: 2007-06-27 15:14
I've done so
; Selected Language
LANG=de
; Prompt the user to before trying to close any applications (0/1)
ASKFIRST=1
; Timeout for the Ask First Prompt (Seconds)
ASKFIRSTTIMEOUT=30
; Default if the askfirst prompt times out (0/1) (1 = Yes, 0 = No)
ASKFIRSTDEFAULT=0
; Text to use for ASKFIRST
ASKFIRSTPROMPT=OK zum Schliessen aller Anwendungen auf Laufwerk X:
; A "Fixed" type drive CAN be ejected (USB Hard Drive) (0/1)
FIXEDOK=1

All that happens now is:
- the prompt appears (X: is replaced by S:)
- immediately after hitting the OK button the eject drive dialog pops up
- nothing else
But like said before, this only happens if PAM is started from run dialog.

ZAP
____________________________________________________________________

PS.
It must be a problem with the working directory:
I have created a shortcut to 'S:\StartPortableApps.exe' with the working directory left blank. What happens is the same as described above. After setting the working directory to 'S:\' it works.
So I won't use 'run' anymore (must protect the shortcut from cleanup while the drive is not connected).

ZAP

steven0451
Offline
Last seen: 16 years 1 month ago
Joined: 2007-06-15 06:07
Portable Firefox no closing

For some reason, it won't eject my drive because of Portable Firefox. It closes the Firefox window, but the firefox.exe process is still running in the background.

(F:\PortableApps\FirefoxPortable\App\firefox\firefox.exe) I think.

I would rather not force it closed because I want it to cleanup any traces left over from browsing.

OpenOffice is also giving me this problem, with the soffice.bin and soffice.exe processes.

Can anyone help?

xrxca
Offline
Last seen: 10 years 1 month ago
Joined: 2007-07-03 23:59
Bug

I know about this one, for some reason it appears that the stub process either has no window or isn't responding to close messages. When I get a bit of time I'm going to do a bit more testing to try an figure a way to get those.
I hadn't noticed the Openoffice one, but I may not have tried ejecting with it running.
_________________________
* programmer (noun) : a predominantly nocturnal creature fueled by either Caffeine or Sugar (Or Both).

_________________________
* programmer (noun) : a predominantly nocturnal creature fueled by either Caffeine or Sugar (Or Both).

steven0451
Offline
Last seen: 16 years 1 month ago
Joined: 2007-06-15 06:07
PStart too

It seems to be quite a big bug because it affects quite a few programs...for example to PStart by Pegtop. I use that menu instead of the official PortableApps menu.

arqbrulo
arqbrulo's picture
Offline
Last seen: 4 years 1 month ago
Joined: 2006-08-10 16:38
Minimize to tray?

I have the Minimize to tray extension, and I know that in my case, if it's in the tray, it won't close. I need to have the Firefox window showing.
---------------
"Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river." -- Cyril Connolly

"In three words I can sum up everything I've learned about life: it goes on." -- Robert Frost
"In three words I can sum up everything I've learned about life: baby ain't mine." -- Adam Holguin

Aciago
Aciago's picture
Offline
Last seen: 5 months 1 week ago
Joined: 2007-01-24 14:23
Closing windows...

Yesterday for the first time, I ran ejectscript with the Documents' Folder open (I always run it with every window closed except those Apps minimized on system tray)... and the script failed to close it... Is that a bug?

BTW, I'm running version 0.3

------------------
May the source be with you!

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 Biggrin

xrxca
Offline
Last seen: 10 years 1 month ago
Joined: 2007-07-03 23:59
Not really.

No its not a bug, I have yet to come up with a consistent and safe* way to find windows of programs that are not run from the drive (ie: explorer which is run from the system drive) but have files or directories open on the drive.

* I have a method that almost works, but every now and them locks up the machine which is no good.
_________________________
* programmer (noun) : a predominantly nocturnal creature fueled by either Caffeine or Sugar (Or Both).

_________________________
* programmer (noun) : a predominantly nocturnal creature fueled by either Caffeine or Sugar (Or Both).

John T. Haller
John T. Haller's picture
Online
Last seen: 42 sec ago
AdminDeveloperModeratorTranslator
Joined: 2005-11-28 22:21
Check your email

xrxca - check your email.

Sometimes, the impossible can become possible, if you're awesome!

dysphasi
Offline
Last seen: 16 years 7 months ago
Joined: 2007-02-07 11:39
Bit confused

Well, I've downloaded this and ran it, all was fine to start, it closed all running apps etc... on the flash drive, but it won't eject the drive, only pop up the "Safely remove hardware" prompt, to eject I then have to click on my drive and select stop->stop.

Am I missing something? Shouldn't this script be doing these steps for me?

Any help would be much appreciated, thanks in advance anyone!

Aciago
Aciago's picture
Offline
Last seen: 5 months 1 week ago
Joined: 2007-01-24 14:23
yes.-

That's precisely how it should work...

------------------
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 Biggrin

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 Biggrin

dysphasi
Offline
Last seen: 16 years 7 months ago
Joined: 2007-02-07 11:39
Ahh.. soz, realise that now,

Ahh.. soz, realise that now, saw the script name and thought that it was meant to eject the drive Blum my bad! .... hadn't read the bit under the original release.

Now I know this is how it is meant to work is there any way I could use this along with something like deveject and introduce the function I am after...ie. the ability to eject the device upon running the ejectscript?

zikarus
Offline
Last seen: 12 years 6 months ago
Joined: 2006-10-10 16:32
Is it possible to run an

Is it possible to run an .exe and a .bat file on closedown?

I would like to unmount a TrueCrypt volume via .bat file (in case it is still open) and then run the RemoveDrive.exe afterwards.

Aciago
Aciago's picture
Offline
Last seen: 5 months 1 week ago
Joined: 2007-01-24 14:23
I

was thinking just the same... lol

------------------
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 Biggrin

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 Biggrin

xrxca
Offline
Last seen: 10 years 1 month ago
Joined: 2007-07-03 23:59
Ummm yes.

at least in the latest version of my menu mod, you could create an ExecOnClose.bat in the menu directory that gets run just before the ejectexe
_________________________
* programmer (noun) : a predominantly nocturnal creature fueled by either Caffeine or Sugar (Or Both).

_________________________
* programmer (noun) : a predominantly nocturnal creature fueled by either Caffeine or Sugar (Or Both).

Aciago
Aciago's picture
Offline
Last seen: 5 months 1 week ago
Joined: 2007-01-24 14:23
Not closing an App.-

Hi xrxca,

I started using a new App I found on portablefreeware, it is called Rainlendar2 (http://www.portablefreeware.com/?id=443), the problem is that when I run ejectscript, it closes the rainlendar icon on SystemTray, but in ctrl+alt+del it still shows the App running, and of course, fails to eject the drive...

Can it be fixed?

Note: Rainlendar don't have a command line option to autoclose it... Sad

------------------
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 Biggrin

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 Biggrin

aero.ag
Offline
Last seen: 16 years 6 months ago
Joined: 2007-08-06 17:37
Not stopping all programs

I recently installed Roboform2go and it just has a tray icon showing that it is running. All programs that are in my PAM close perfectly, but is it possible that the script does not close apps that I do not have in the PAM? Right now I still have to right click on my roboform icon and select exit before it will stop. Can anything be done to that?
Thanks

dysphasi
Offline
Last seen: 16 years 7 months ago
Joined: 2007-02-07 11:39
Ok, I've now set up the

Ok, I've now set up the ejectscript's ini file to run removedrive.exe.

This works fine as long as I set my drive's letter in the ini file, however using my usb drive on multiple computers, I really want to be able to eject the drive no matter what letter is assigned to it.

Running remove drive standalone I'd be able to do this with the following command:

removedrive.exe "USB\VID_0781&PID_5406\0000174F8860925A"

is there a way I can stop ejectscript assigning a drive letter and instead make use of my device id?

dysphasi
Offline
Last seen: 16 years 7 months ago
Joined: 2007-02-07 11:39
Someone please shoot me

I do believe I'm the dunce of the day. Got it working now as I want. For any fellow dunces out there, I just had to change the below lines in ejectscript.ini as follows:

; Show Safely Remove Hardware Dialog (1/0)
SHOWDIALOG=0

; EJECT Exe, the Executable that will be run at end of this script
EJECTEXE=.\removedrive.exe

; Command Line Parameters sent to the EJECTEXE program, X: will be replaced with the drive to eject
EJECTPRM="USB\VID_0781&PID_5406\0000174F8860925A"

N.B.
- removedrive.exe is placed in the same location as ejectscript.exe

- I find the easiest way to get the Device ID is by using ListUsbDrives.exe
(Download "USB drive letter manager" from http://www.uwe-sieber.de/usbdlm_e.html to get hold of this)

xrxca
Offline
Last seen: 10 years 1 month ago
Joined: 2007-07-03 23:59
or just use X:

In the ejectscript.ini file just put Secret on the EJECTPRM line, and the Secret will be replaced with whatever the drive letter on the current machine is.

I use that myself because I have hmm... counting here...
At least 9 USB flashdrives, 2 - 2 1/2 inch usb hard drives and a half dozen 3 1/2 inch usb hard drives (although all the 3 1/2's are used to backup my backup system in rotation)

But if I copy the apps to another drive I don't want to have to figure out what the ID is going to be
_________________________
* programmer (noun) : a predominantly nocturnal creature fueled by either Caffeine or Sugar (Or Both).

_________________________
* programmer (noun) : a predominantly nocturnal creature fueled by either Caffeine or Sugar (Or Both).

didilalalaport
Offline
Last seen: 16 years 7 months ago
Joined: 2006-11-22 01:16
request to add an option

I use an autorun utility on the host pc to start PAM, there for ,(APO usb autorun),for instance tie itself to the drive so it prevent the eject to work, would it be possible to add option to specify an aplicatition to kill before the eject then
restart it if nedded???

zikarus
Offline
Last seen: 12 years 6 months ago
Joined: 2006-10-10 16:32
You are right xrxca - BUT

You are right xrxca - BUT this would cause an unmount of the TC-volume not on eject alone but also when the Menu is simply closed. It would be nice to have this separated in some way, since the TC-volume should only be umounted on eject - at least in my configuration ;-)...

Edit: Uups, this post landed in the wrong row - referring to an opportunity to run a .bat file before RemoveDrive.exe to always unmount a possibly mounted TC-volume on eject...

xrxca
Offline
Last seen: 10 years 1 month ago
Joined: 2007-07-03 23:59
How about this

Haven't tried it, but I THINK it will work.
Try putting a .BAT file in the EJECTEXE entry of the ejectscript.ini file, I'm pretty sure it should allow it and your batch file could umount and then run removedrive.
_________________________
* programmer (noun) : a predominantly nocturnal creature fueled by either Caffeine or Sugar (Or Both).

_________________________
* programmer (noun) : a predominantly nocturnal creature fueled by either Caffeine or Sugar (Or Both).

zikarus
Offline
Last seen: 12 years 6 months ago
Joined: 2006-10-10 16:32
Will give it a try asap and

Will give it a try asap and report...

zikarus
Offline
Last seen: 12 years 6 months ago
Joined: 2006-10-10 16:32
Well it took me some time,

Well it took me some time, but as far as I can tell it does not work via a .bat-file instead of an .exe...

Tried a .bat that was supposed to do three things on eject:

1. Run subst.exe in order to log off a drive B:
2. Run TrueCrypt.exe in order to log off all TC-volumes
3. Run the RemoveDrive.exe

If there is an easy way to let one (or some) .bat files be run before the RemoveDrive.exe will run it would be great to have this implemented too...

Darkness
Offline
Last seen: 16 years 6 months ago
Joined: 2007-07-31 20:13
This is a great script but

This is a great script but unfortunately it's now being picked up as a virus by AVG obviously I know it's not, but because it's being picked up as one it doesn't work. Since most of the computers I use have this installed it's become a bit of a problem. Will there be a fix to this?

ZachHudock
ZachHudock's picture
Offline
Last seen: 1 year 2 months ago
Developer
Joined: 2006-12-06 18:07
Others have said AVG detects

Others have said AVG detects it as well. The fix would be to contact AVG and tell them they are incorrectly flagging something.

I believe this is being flagged as a virus because it was written in AutoIt. AutoIt can be used to automate tasks, create system changes, and do several other things.

You can see from the source code for EjectScript that it does not contain any malicious scripting, but because of AutoIt's power, there is a potential for it to be used maliciously.
_________________________
I don't believe in signatures

The developer formerly known as ZGitRDun8705

foshdafosh
Offline
Last seen: 1 year 9 months ago
Joined: 2007-07-31 08:12
HTA file isn't closed

Hi there,

Just in case it's of interest, my running hta application isn't closed by the eject script.

The command line it's launched with is:
"C:\WINDOWS\System32\mshta.exe" "E:\PortableApps\RepairKit\Builder.hta"

Really handy gizmo though, thanks very much!

Cheeer,
Pete

Log in or register to post comments