You are here

Eject Script Version 0.3

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

EjectScript (written using AutoIT) Version 0.3
Added optional prompts before it tries to close any applications, and before it runs any external Eject EXE program.
Information and Download
If you could let me know what apps (running off the portable drive) it won't close it would be appreciated.

0.2: Still no direct drive eject, but minor updates to try an increase the number of applications it will close, and added the drive type to the output of EjectScript /SHOW to help diagnose why it says some drives are not ejectable.

incubus
Offline
Last seen: 16 years 7 months ago
Joined: 2007-06-23 21:33
works

no probs

greetz

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

Is there a way to close processes running from the usb drive? I'm talking about programs that don't have windows or are disabled.
---------------
"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
It's in there

As long as you know the full path you can specify an application to close that has no window.
Create yourself an ini file (use EJECTSCRIPT /INI to create a default one), and add your app to the APP_NOWINKILL section

[APP_NOWINKILL]
0=X:\Full\Path\To\App.exe
1=X:\Full\Path\To_Another\App.exe
...

Make SURE you use Secret for the drive, it will get replaced with the current drive.
You may want to play with the FORCETIME and NOWINTIME settings.

_________________________
* 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
Well xrxca as discussed here

Well xrxca as discussed here ( https://portableapps.com/node/7878?page=1 ) the RemoveDrive.exe delivers excellent results. My .bat file simply made it work for me. The only thing missing right now is some line(s) that force(s) the eject to run automatically if someone does not enter any correct answer to the question after a given period of time in seconds...

Did not know, that you built in the possibility to use it in your script already. But I have to admit that I am a bit confused about how to use (meaning modify) this script via an .ini file anyways. Could you maybe describe it a bit more 'practical' for a dummy like me Smile I would love to use your script in conjunction with your Rolled Blue theme and RemoveDrive since that would run even 'cleaner' with your extra button...

As for the remove.exe I believe you have chosen wrong switches in your short example given. I could not find -s and -b to work correctly with the actual removedrive.exe. Only -l, -h -d and -w:... That's at least what the included text file of RemoveDrive suggests.

Looking forward to your next PAM mod release btw.!

BR
z

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

With the version I have, the text file is WRONG.

At a command prompt type removedrive without any switches and it gives a list of available switches, I went from that, not the text file (which has just the lhdw flags in it).

_________________________
* 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
Another observation:

Another observation:

Closing PAM modr21b via the usual x-button with the ExecOnClose function set to run the remove.bat posted in the other thread ejects my drive properly when answering yes to the popping up question.

I have now tried something else and changed the path of your special Eject button to hint at the same .bat file. And even though path and command switches used are all the same, I am not able to eject the drive this way due to some open handles (which is strange enough, since there was no application started besides PAM).

Maybe using your script together with RemoveDrive will work properly, but I have not yet been capable to set this up...

And before I forget: Could it be, that your script changes something upon the Windows selecting drives dialog in some way? After downloading the new script (02) extracting it to where it should be and running it off my drive for the first time, this dialog seems to be broken somehow. The native language seems to be replaced by English and it is not possible to select any drive anymore. First I thought it would be a problem with PStart alone (which I was trying to get to scan a certain drive) but later I discovered, that the select a drive dialog does not let me choose one and crashes whenever it is offered... Please don' t get me wrong here, I do not want to blame your script at first hand, just asking whether it could be reason for this unfamiliar behaviour...

xrxca
Offline
Last seen: 10 years 1 month ago
Joined: 2007-07-03 23:59
First the eject button is

First the eject button is meant to be connected to something that closes apps, it does NOT close PAM in and of itself, pam gets closed by my eject script. That is the main purpose of the eject script, to shutdown programs running off the USB stick.

And I would bet that if you have any other programs still running off the stick (besides PAM) when you try your bat file you'll get the same result, removedrive won't close programs.

Look at the source, there is NOTHING in it that should do anything to any default windows dialog PERIOD. I have run it hundreds of times during testing, and I even checked the autoit forums incase there was an issue there that I knew nothing about, but was unable to find anything in any way related.
_________________________
* 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
I have meanwhile run your

I have meanwhile run your script with an .ini file pointing to RemoveDrive.exe many times.

But I still get the same results:

Ejecting the drive (without anything running but PAM) via the Eject-button does not eject my stick - closing PAM via the x-button with the ExecOnClose function pointing to the RemoveDrive.exe via the .bat file does.

Since RemoveDrive.exe is run in exactly the same manner both ways, the reason for the difference must lie somewhere else...

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

You made to the ejectscript.ini file, without that there is no way to diagnose anything.

Does PAM close when you use the eject button with my script?

Does removedrive run?

Turn off the EJECTHID option (set EJECTHID=0 in the ini file) to see removedrives window.
_________________________
* 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
The .ini has been changed

The .ini has been changed like this:

; EJECT Exe, and Executable that will be copied to %TEMP% and run at end of this script
EJECTEXE=X:\Apps\RemoveDrive\RemoveDrive.exe
; Command Line Parameters sent to the EJECTEXE program, Secret will be replaced with the drive to eject
EJECTPRM=X: -l -d -w:2000
; Run the Eject EXE Hidden (1/0)
EJECTHID=0
; This script should handle deleting the EJECTEXE program from %TEMP% after it runs (0/1)
EJECTDEL=0

As I said, the switches are the same as used for the .bat.

PAM is closed down and the RemovDrive.exe begins to run, but gets hung up in a loop before it displays a failure.

Since the message window of he RemoveDrive seems to be fixed I cannot see which process causes the loop (the important part of the repeatedly displayed messages is cut off on the right hand side of the message window). It is a VetoType=6 though...

xrxca
Offline
Last seen: 10 years 1 month ago
Joined: 2007-07-03 23:59
Thoise options work fine for me

Do you still have the INI file open when your doing this? (removedrive sat and looped till I closed the file)

And the removedrive output is wrapped on screen so you should see it all.

Vetotype 6 is a file open on the device, change the -d to -h in the ini file and run it again, all you 'should' see is ejectscript.exe which goes away shortly after removedrive is started, if there is anything else there is a problem. One thing I wonder about is do you still have the removedrive.bat set to run on pam exit, if so you may have two copies of removedrive arguing with each other.
_________________________
* 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
Works good.-

I like this new version a lot, it works way better than the old one...

Just one question... (mmm, how can I explain myself?) ... well two, lol -> Do you know that little icon with the green arrow in the system tray? the one you press to eject the Pdrive... well, do you know the difference between right-click and left-click that icon? Ejectscript act as a right-click... ok, this is the third question, but it's the real one, hehehe... is there any way to make ejectscript to act as left-click?

Do you know what is the best with ejectscript? my laptop at home never show me the little icon to eject the Pdrive, with ejectscript I don't need it... Wink

------------------
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
Left click

The problem is the menu that pops up on left click is not a dialog, and I could find no consistent way to get that to pop up (The key is consistency, I want it to work on most any machine I pop the USB stick into) There is no set location for it, and although I am able to find the window handle of the icon it wouldn't respond to messages properly (especially if it was currently hidden) and worse it is not persistent (it disappears if you click elsewhere, or are slow lifting UP the mouse button from the button that popped it up).
_________________________
* 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
you're right

The actual way should work in most circumstances and specially when you have more than one drive connected and need to choose which one is the one you want to close...

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

dragonmage
Offline
Last seen: 1 year 2 months ago
Joined: 2007-01-15 02:25
Idea for difficult to close programs

xrxca , could you change PAM so that the "Exec on Close" option opens a dialog where you can set the path and arguments to an app? Difficult programs that happen to have their own exit switch could then be set to close themselves rather than trying to have another script or program attempt to close them.

Just an idea.

xrxca
Offline
Last seen: 10 years 1 month ago
Joined: 2007-07-03 23:59
I like the idea

I will work on adding it, it will pretty well have to be a separate item, 'exec other on close', I've been thinking of a way to be able to specify an eject script from within PAM and this could be the answer, just a list of apps to run with parameters when PAM closes.

That said I'm running a bit behind on my current changes. I didn't hit a wall, but after climbing over a hedge or two (working around limitations with the current code/data layout) decided that there was a far better way to store and work with the application data and scrapped a bunch of my changes (not to mention quite a bit of the original code).
_________________________
* 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).

dragonmage
Offline
Last seen: 1 year 2 months ago
Joined: 2007-01-15 02:25
Just thought of an idea. It

Just thought of an idea. It might be an easier way for you to do it.

Click "Exec on Close"
Dialog opens to enter parameters in (path should already be filled in)
Click Ok

If you don't need it to run parameters just click Ok.

kastro
Offline
Last seen: 15 years 4 months ago
Joined: 2007-01-04 00:46
Didn't work with my WD 6GB Micro USB HDD

I had to modify the script by commenting out line 323:
If Not StringInStr(" REMOVABLE CDROM ", DriveGetType($Drive)) Then ExitError($Msg_ErrType) ; Not on a Removeable Drive

xrxca
Offline
Last seen: 10 years 1 month ago
Joined: 2007-07-03 23:59
What did the script think your drive was?

If you run ejectscript /show from the drive it should tell you what the drive is, I think this may be a bug in AutoIt as it may be identifying some Removable drives as Fixed drives. If this is the case I'll add an override to allow it to run on a "Fixed" drive as long as it isn't the system 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).

kastro
Offline
Last seen: 15 years 4 months ago
Joined: 2007-01-04 00:46
It is the "Fixed" type

Eject 0.3
--------------------------
Applications With Windows
D:\PortableApps\PortableAppsMenu\PortableAppsMenu.exe
D:\PortableApps\KeePassPortable\App\keepass\keepass.exe

Applications Without Windows
D:\PortableApps\KeePassPortable\KeePassPortable.exe
--------------------------
DriveType for D: = Fixed

kastro
Offline
Last seen: 15 years 4 months ago
Joined: 2007-01-04 00:46
You should just remove the

You should just remove the line completely. You check to see if PAM is running on an OS Drive and when I put it on another fixed drive, Windows XP will error and not allow an Eject.

Is there a way I can change the removable HDD to a "removable" type drive?

Patrick Patience
Offline
Last seen: 4 years 3 months ago
DeveloperModerator
Joined: 2007-02-20 19:26
Can you.

Make it so my drive shoots out of the port when the script is run? Blum

_______________________________________________
It's kinda scary when my desktop is messier than my room...

Zappa
Offline
Last seen: 12 years 3 months ago
Joined: 2007-06-27 15:14
Doesn't it

already ... ?

dragonmage
Offline
Last seen: 1 year 2 months ago
Joined: 2007-01-15 02:25
And then turn into a little

And then turn into a little robot which jumps into your pocket?

Patrick Patience
Offline
Last seen: 4 years 3 months ago
DeveloperModerator
Joined: 2007-02-20 19:26
Yes.

I want that too. Soon pleazee. Blum

_______________________________________________
It's kinda scary when my desktop is messier than my room...

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

The 'Robot' API has way to many bugs in it, and really only works properly in Windows 2029 (Of course the Skynet addon has to be installed)
_________________________
* 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).

Log in or register to post comments