Here's a scaled-down test case of my little script:
-- We refer to applications by id rather than name in case of localization
tell application id "com.apple.systemevents"
set everyProcess to bundle identifier of every process
-- Start by quitting System Preferences, since we're installing a new pref pane
if "com.apple.systempreferences" is in everyProcess then
-- activate first, so that if quitting the app presents a dialog, it will be visible
tell application id "com.apple.systempreferences" to activate
end if
end tell
As I noted, this works fine in Script Editor. If System Preferences is running, it comes to the front. If it's not running, nothing happens.
If I save this as a text file, then run it via osascript:
osascript myScript.txt
...then System Preferences launches to handle the "activate" message.
I've tweaked the script to show me the contents of everyProcess, and com.apple.systempreferences is in there. Am I doing something wrong (e.g. with my "is in" syntax), or...?
I'm sorry if this is a n00b question, but I'm a 20-year C++ programmer working my head around AppleScript. ;-)
Thanks much,
--Mike
PS: I've developed what I think are a couple of very handy scripts for Safari. Is there a good place to post them?