I resented the fact that I could not launch an application if another user logged into my computer had left it open. Here is the solution to launch an application another user has left active in Panther, with the example of iTunes.
- We need a shell script that will explore processes and kill iTunes.app if it finds one
- We need this shell script to have administrator privileges, even for the "Guest" account
- We want to wrap around this shell script a nice GUI
[robg adds: The following script will quit iTunes, regardless of where it was launched. Just remember to check first before trashing someone's iTunes; it's possible that iTuness may be busy re-sampling all MP3s when you merrily toss it out of existence!]
- The shell script to quit iTunes left open by another user:
If you're new to shell scripting, do this:#!/bin/sh ok=`/bin/ps -auxww | /usr/bin/grep iTunes.app | /usr/bin/grep -vc grep` ; ko=1 if test $ok = $ko; then kill `ps -ax | grep iTunes.app | grep -v grep | awk '{print $1}'` fi open -a "iTunes"- Copy the code above
- Open Terminal in Application > Utilities
- Type emacs /itunes_launcher.sh
- Type Command-V
- Type Control-X then Control-S (to save)
- Type Control_X Control-C to quit emacs)
- Now we need to execute the script with administrator privileges. I presume you have named your script itunes_launcher.sh, and that it is at the root of your OS X disk. Copy and paste these lines, one by one, into the Terminal:
This changes ownership of the script to root, makes it executable, and operates with root privileges when executed.% sudo chown root /itunes_launcher.sh #(you will be prompted for admin password) % sudo chmod +x /itunes_launcher.sh % sudo chmod u+s /itunes_launcher.sh
- Now we need a nice GUI around this. Launch Script Editor in Applications -> Applescript, and copy and paste the following:
Save your AppleScript as an application, leaving all options checkboxes blank, give it the name you want in the place you want. To launch iTunes, double-click on it.do shell script "/itunes_launcher.sh" quitBonus: I wanted my AppleScript to have the same icon as iTunes and place it in my dock. Find your iTunes in folder Applications. Click on it. Hit Command-I (to open the information window). Then click on the icon. Hit Command-C (to copy the icon). Now close information window of iTunes and open that of your script. Instead of hitting Command-C, hit Command-V (to paste the icon). You're set!
Repeat step three for each of your users. This is it. Security concerned? No, iTunes won't be launched with root privileges by the shell script. The command open -a launches an application with its normal privileges.

