Deleting scripts

What is the best way of creating a script such that when done it deletes itself?

I’m planning on copying a scirpt to currently logged in user’s desktop and after pefroming its task I’d like for the script to delete itself. The command to delete will also have to be profile/user independent since the script will be pushed to different machines.

The script will be modifying Entourage account settings.

Would this be the best way of going about this?
Would there be a better place than Desktop?

I’m a novice at this and so far this is what I’ve come up with for deleting script which does not work.

tell application “Finder”
delete file “script_name” of folder “Desktop” of folder “user n” of startup disk
end tell

Thanx in advance,
Cyrus

This script, saved as an application called ‘DeleteMe.app’ on my own desktop deleted itself with the file ending up in the trash:

tell application "Finder" to delete alias ((path to desktop folder as text) & "DeleteMe.app")

and this one, deleted itself without a trace:

do shell script "rm ~/desktop/DeleteMe.app"

Adam,
Thanx for the feedback. I’m having trouble making this work. Adding your suggested line results in the following message.

Being new to this forum I started searching and found he following which is working for me.

tell application "Finder"
	move (application file of application process "file_name" as alias) to trash
end tell

I would still like to find out why your method is not working.

Thanx,
Cyrus

In both cases, my scripts work if the script is saved as an application AND run by double-clicking it on the Desktop. They return the error you describe if run by clicking on the Run button in the Script Editor.

EDITED: Adam beat me to it.