Can Finder Terminate running processes??

Hi gang,

I’ve been trying to get Finder to force all non-essential processes (running applications) to quit.

I first tried this script… (thanks TJ)

tell application “Finder”
quit (every process whose name is not “loginwindow” or name is not “SystemUIServer” or name is not “finder” or name is not “dock”)
end tell

… The result is that the Finder quits and all other apps stay open!.. I then tried a number of other scripts based on the same principle of identifying the process name and then trying to quit the process. Same result with all attempts.

I reached the conclusion that Finder itself is executing the “quit” command without resolving the arguments which follow.

I’ve had some success by first identifying the name of a process and then telling the matching application to quit, using a script like

tell application processname
quit
end tell

However this is raising some other problems in the environment I’m running and I believe I really need to tell the process to quit rather than telling the application to quit.

Does anyone have any ideas on how to tell a process to quit??,

Cheers,

Graham

Hi Graham,

You might want to take a look at the dictionary for System Events. It’s more direct than using the Finder in some cases since some of the Finder’s commands are passed to System Events anyway.

You’ll see that the dictionary has terms for ‘process’ and ‘application process’, just like the Finder. I’m not sure what difference it might make. Maybe it’s important and maybe it isn’t. One problem that you might encounter when quitting processes is where the script encounters an app with a unsaved window or document. It might cause the app to throw a dialog asking about saving. If it doesn’t cause an app to ask, I’d be inclined to think that it’s a dirty way to close stuff and undesired results might occur. I haven’t messed with this type of stuff so I can only offer conjecture.

Good luck! Oh yeah! Feel free to share what you learn. :wink: