I have a script that worked in Jaguar and no longer seems to work in Panther (10.3.2). Can anyone confirm this for me? I think the problem is that the ‘delete login item’ line no longer works.
Is there another way to do this?
Thanks for your help
John M
–My Script
set run_path to (path to me) as text
if run_path contains "Script Editor" then
display dialog "This script must be run as an application to operate correctly." �
default button 1 with icon 2
end if
tell application "System Events"
get (name of every process whose name contains ("System Preferences" as text))
if result contains "System Preferences" then
display dialog "System Preferences is open." & return & return & �
"Quit System Preferences, then re-open this script to complete this setup."�
buttons [" OK"] default button 1 with icon 2
return
end if
delete login item “My Script” --The name of an existing login item
make login item at end with properties {path:(path to me), hidden:false}
delete (every login item whose name contains “Script Editor”) --To remove addititons of Script Editor from Login Items
end tell
Works fine here in 10.3.2. Try this script. It will get the properties of your first login item, delete it, and create it again at the end of your login items (note the POSIX path notation for the path to the item):
tell application "System Events"
try
set the_props to properties of login item 1
delete login item (name of the_props)
return properties of (make login item at end with properties {path:(path of the_props), name:(name of the_props), hidden:false})
on error the_error
return the_error
end try
end tell
I’ll try that, but what if the login item isn’t item 1? I want to reference it by name.
I think I’ve a solution. I just changed the offending line to-
delete (every login item whose name contains “My Script”) --The name of an existing login item
This seems to work, although I don’t really see the difference.
I have a second question. Is there a way of triggering a script after fast user switching?
In my code, I do delete the login item by name. Since I didn’t know any of your login item names, I copied the name from your first login item then used that name for the delete code. To see the names of all your login items, try this code:
tell application "System Events" to return name of login items
As to executing a script on FUS, check out the freeware FUS++ that adds this capability and more.