I am trying to include a check box into my app to allow the user to set my app to start at login. It works getting the app into the login items for now, but I am stuck on one part.
Right now my code is:
try
set appPath to ((path to applications folder as Unicode text) & "Example.app")
on error
display dialog "Please put Example.app in your Applications folder."
end try
tell application "System Events"
make login item at end with properties {path:appPath, hidden:false}
end tell
It works in that it puts something in the login items, but its not putting the actual application into the login items. It is putting Machintosh HD/Applications/Example.app into the login items with a type of “Unknown.” I have even dragged the actual .app file into the Applications folder but it is still not putting the app in the login items. I have a feeling that the “set apppath…” line is making the path no matter what and not actually checking to see if the .app is in that path. What could I be doing wrong?(the on error part is suppose to trigger is the .app isnt in the app folders, but it isnt for some reason)