Force quit all question

I’m trying to force a logoff and force quit all user processes with the following script:

tell application "System Events"
	do shell script "killall -u myusername"
	delay 5
	keystroke "q" using {shift down, command down}
	set frontmost to true
	delay 1
	keystroke return
end tell

However, some applications return with a dialog to confirm a quit which I don’t want. I should also note that this script should work independent of which application is open.

Any ideas?

try a

killall -u user -9

I had tried that also but to no avail. For example, when an unsaved document is open in ScriptEditor, the app will ask for a confirmation. The same when multiple tabs are open in FireFox.

how about killing all process themselves and then logging the user out… this is the code I use in a application of mine

set exclude_apps to {"Finder"}

tell application "System Events" to set the_apps to name of processes whose background only is false

repeat with the_app in the_apps
	if exclude_apps does not contain the_app then
		tell application the_app to activate
		try
			do shell script "/bin/kill `ps ax -w | awk /'" & the_app & "'/ | awk '{print $1}'`"
		end try
	end if
end repeat

tell application "System Events" to log out

Perfect that is exactly what I was looking for! There is only a tiny error in your script, the scriptapplication should be on the list of excluded programs as well. Otherwise the log out comand will be ignored.

Heheh well my actualy application of this is a Xcode App and yeah I have the name in the excluded apps list… I removed it here since it didn’t apply. that is unless you have an app named Phoenix you want to not be quit.