Ejectscript (c) 2007 Karl McMurdo usage: EJECTSCRIPT [/?] [/INI] [/SHOW] [X:] [lang] /? Show This Help Message /INI Create ' & $Basename & '.ini With all default values /SHOW Show any Applications Running on Current Drive X: Try Closing Applications Running on Drive X: lang Create a blank Locale file ' & $Basename & '_lang.locale the file must NOT already exist, "lang" will be what is used in the ini entry LANG= to set the language, it must be at least 2 characters long, and can contain only letters numbers _ and - (but can not start or end with either _ or -. Short but self explanitory is best. This script will try to close all windows running off a portable device, it has the following capabilities Create a default Config File, you can create a config file with all the available options in it along with descriptions of the options by running EJECTSCRIPT /INI the program will prompt you to overwrite the file if it already exists. In the ini file is an option is an on/off optio the values need to be either 1 for On or 0 for Off, Other than the Application Lists all configuration options are in the [CONFIG] section of the INI file. Customizable Messages (Language or just customized) to create a locale file that can be customized run the program with a 2 or more character alphnumeric parameter, for instance if you run EJECTSCRIPT de a file named EjectScript_de.locale will be created with every customizable text message in it (including comments for the default config file) to get the program to use this file, put LANG=de in the CONFIG section of the INI file. Config Option: LANG= Default = none Optionally Prompt the user to before trying to close any applications. Config Option: ASKFIRST= Default = 0 Timeout on message box (In Seconds) Config Option: ASKFIRSTTIMEOUT= Default = 300 Default Answer (On Timeout, and which button is selected by default) Config Option: ASKFIRSTDEFAULT= Default = 0 (1 = Yes, 0 = No) Prompt displayed to user (X: is replaced by current drive) Config Option: ASKFIRSTPROMPT= Default = OK to try closing applications running on drive X: Optionally Allow Attempting to Eject a "Fixed" drive (some USB hard drives report themselves as "Fixed" instead of removable.) Config Option: FIXEDOK= Default = 1 Quiet Mode, the popup info tip will not be display nor will any error messages Config Option: QUIET= Default = 0 Optionally Show the Operating Systems Safely Remove Hardware Dialog Config Option: SHOWDIALOG= Default = 1 Run another program before exiting, you can specify another program to run before this program exits. Specify the path either relative to where the ejectscript is run from, or absolute (X: will be replaced with the current drive Letter) The program will be copied to the current %TEMP% directory (usually under the current users profile directory) and run from there. Config Option: EJECTEXE= Default = none Command line parameters can be specified for the EJECTEXE program Config Option: EJECTPRM= Default = none The EJECTEXE program can be run hidden or not. Config Option: EJECTHID= Default = 1 The EJECTEXE program can be deleted after it has run, this is done by also copyiong this program to the %TEMP% and runnign a second copy with special parameters that will then wait for the EJECTEXE program to finish before deleting the EJECTEXE program and itself. Config Option: EJECTDEL= Default = 0 Optionally Prompt the user to before trying to run the EJECTEXE. Config Option: EJECTASK= Default = 0 Timeout on message box (In Seconds) Config Option: EJECTASKTIMEOUT= Default = 300 Default Answer (On Timeout, and which button is selected by default) Config Option: EJECTASKDEFAULT= Default = 0 (1 = Yes, 0 = No) Prompt displayed to user (X: is replaced by current drive) Config Option: EJECTASKPROMPT= Default = OK to Try Ejecting Drive X: Specify the minimum amount of time (in seconds) the popup top will display, the tip will display for as long as the program is running, but if the program is ready to exit before this time has expired it will wait that long before exiting. Config Option: TIPTIME= Default = 3 Specify Application paths that should be killed if they don't close after a specified amount of time, the programs must be specifed with the FULL path on the portable drive, to get a list of what is running on the drive, run EJECTSCRIPT /SHOW the program will try closing the window first, then after the specified time will try killing the window, wait a very short time, then if the window still exists try closing the process directly. The time to wait is configurable in seconds. Config Option: FORCETIME= Default = 5 The list of programs is in configuration section [APP_FORCETIME], and MUST start with X:, the key on the left side of the ini line can be anything but must be unique (I suggest numbers) ie: [APP_FORCETIME] 0=X:\path\App1.exe 1=X:\maybe\another\path\app.exe Specify Application paths whose windows should be killed instead of closed by default, if they windows do not close, they will be given the same treatment as the APP_FORCETIME windows after the FORCETIME timeout. I tend to use this instead of APP_FORCETIME for difficult applications. Configuration Section [APP_FORCEALWAYS] Specify Applications that have no windows whose processes should be killed after FORCETIME has expired. instead of closed Configuration Section [APP_NOWINKILL] This waits for a specified amount of time AFTER FORCETIME has expired before going to this extreme. Config Option: NOWINTIME= Default = 5 Specify Applications to just show the windows of instead of trying to close them (occasionally this will bring normally hiddin windows into view which can be odd) Configuration Section [APP_SHOW] Specify Applications to just ignore (besides this program) Configuration Section [APP_IGNORE] List all applications running off a specified drive Running EJECTSCRIPT /SHOW will create a list of all applications running of the current (or specified drive) (I sometimes use this on a machine with problems (EJECTSCRIPT /SHOW C:) to get a list of apps running (not perfect, but a help) More info and download available at http://portableapps.xrx.ca/ Version History 20070711 n/a - Initial Release 20070716 0.2 - Updated to try multiple loops if windows found, and display drive type on /show output 20070718 0.3 - Added prompt options (before trying to close and before running eject exe)