How to make Applescript quit a specific program for all users? My wife and I are set up on a single laptop and I have our iTunes libraries stored on an external HD. I'm writing an applescript to auto eject that drive when we want to take the laptop elsewhere (we normally use iPads around the house), but I'm having trouble getting the script set up to also quit iTunes for both of our accounts when run.

Here's the basic script right now which is obviously missing the magic to quit iTunes for all logged in users:

tell the application "iTunes" to quit

tell the application "Finder"
    if disk Media exists then
        eject disk Media
    end if
end tell


Any suggestions?
Use the do shell script directive in AppleScript:

do shell script "sudo killall iTunes"

tell the application "Finder"
    if disk Media exists then
        eject disk Media
    end if
end tell


You'll need to make sure that you can execute sudo killall with no password.