Updating an application by itself

Sorry if this was asked before, quick search didn’t show me.
What is the ‘best’ way to update an application to a higher version that I make in AStudio? I create the app, and on our company’s internal local server I can post up the ‘new’ version. How can I update the application from itself as it’s running. (PS I haven’t even tried yet) but should I try to throw the current running app in the trash (can’t imagine I can even do that) and copy the new one to the local HD? Rename the (old) running one, copy the new one, then quit the old one? Try to simply copy all new compiled components from the application package into the old running app (and make sure the ‘updater script’ is its own non-changing script file)?
How do the more commercial applications update themselves from the net?
Suggestions appreciated!
Chris

you could always try this:
http://sparkle.andymatuschak.org/

I’m planning on trying out Sparkle myself.

Sparkle looks spiffy, but I don’t think I am going to be able to use appcasting. I just have the lastest version sitting on a local server. Any other suggestions?

Yeah, you can try this :
(i used it before i start to use Sparkle)

try
			set new_version to do shell script "curl http://www.YOUR_WEBSITE.com/most_recent_app_version.txt"
			--display dialog new_version
			if new_version is greater than version then
				display dialog "A new version (" & new_version & ") is available."
				try
					set DL_link to "http://www.YOUR_WEBSITE.com/updates/YOUR_APP_NAME_" & new_version & ".zip"
					set the destination_file to ((path to preferences as string) & "YOUR_APP_NAME_" & new_version & ".zip")
					-- téléchargement de l'URL :
					tell application "URL Access Scripting"
						download DL_link to file destination_file replacing yes
					end tell
					tell application "Finder"
						open destination_file
					end tell
					display dialog "An update of  YOUR_APP_NAME has been downloaded (v." & new_version & "). The application has been moved to your Applications forlder. Now it's going to launch it."
					tell application "Finder"
						move destination_file to the trash --move the .zip to the trash
					end tell
					set app_in_pref to ((path to preferences as string) & "YOUR_APP_NAME " & new_version)
					tell application "Finder"
						--set dest_fold to (path to applications as string)
						move app_in_pref to the folder "Applications" of startup disk replacing yes
					end tell
					try
						set the_appPath to path to me as string
						set pref_folder to (path to preferences) as string -- pathway to the user preference folder :
						set path_to_file_pref to pref_folder & "AAAAA"
						try
							set the_folder to read (alias path_to_file_pref)
						on error
							set the_folder to (path to preferences) as string
							write_to_file(path_to_file_pref as file specification, the_folder)
						end try
						
					(*	-- checking and creating the file containing the pathway to the old app i used this in my app to put the old app to the trash when the new starts :
						set Path_user to {the_appPath}
						set the_path to (the_folder & {"App_Path.txt"})
						try
							set Path_user to {the_appPath}
							write_to_file(the_path as file specification, Path_user)
						end try
					on error
						display dialog "Can't get path to the app" *)
					end try
					-- open the new app quit the old :
						tell application "Finder"
						open file ("YOUR_APP_NAME " & new_version & "") of folder "Applications" of startup disk
					end tell
					quit the application
				end try
			end if
		on error
			display dialog "Can't get the version of the current application"
		end try

That is a pretty nice looking script. It appears to rely on the version number to be added to the application, something which I generally don’t do with my studio apps.

My latest idea, but I haven’t tried it, is to: Make an updating script, a self running regular Applescript, and put that in the resources folder of the studio app. It will have all the individual components that need updated, hard coded into it. Essentially all files inside the Application.app folder, except the self runnning script. When the user clicks update, the self-runner runs independantly from the actual app. It will quit the App. It will copy all the components from my new version on the updated program on the server. Then tell the App to restart itself, which now has all the new components inside of it. I’m making a big assumption that replacing individual files inside the Application.app folder will not break it!

Any opinions or experience doing that? Will post results when I try it.

Where would this AppleScript look for updates?

Well I am building this in my own company, on our internal LAN. So the people using it would only have to have the appropriate server mounted. I realize this kind of solution won’t work for home users or the world at large, only my little controlled microcosm.