Putting an app into the applications folder

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)

It looks like this:

http://myskitch.com/macman12/picture_1-20071022-180214/

Maybe there is a way to make sure the file is there before actually making the path, like

Alias Example.app

or sometihng like that…

Am i close?

I believe System Events is expecting an alias, but you’re providing it with Unicode text.

Neither HFS path nor alias, the expected path is a POSIX path

try
	set appPath to "/Applications/Example.app"
	POSIX file appPath as alias -- check if file exists
	tell application "System Events"
		make login item at end of login items with properties {path:appPath, hidden:false}
	end tell
on error
	display dialog "Please put Example.app in your Applications folder."
end try

Thanks so much, it worked like a charm!