How to move App to Applications folder when running it?

What I’m trying to do is that when the user runs the App from outside the Applications folder, a display alert appears asking if he wants to move the App to the Applications folder if the App is not already there. I tried the following:

tell application (path to frontmost application as text)
        set myApp to path of document 1
        set folderApplications to "/Applications" as POSIX file
        set anyApp to "/Applications/" as POSIX file
        tell application "Finder"
            if exists anyApp then
                display alert "There is already an App with the same name in Applications Folder.
                tell application "System Events"
                    move myApp to folderApplications
                end tell
            end if
        end tell
end tell

but I get the following error: ERROR: Can’t get «class FTPc» of document 1. (error -1728)
Note: In the Script Editor it works well.

The property label to obtain file path of a document is not only a “path” but also a “file” and so on.

--Script Editor
document -- A document.
	path Unicode text -- The document's path.

document -- A document.
	file (r/o) file -- Its location on disk, if it has one.

document -- A document.
	file (r/o) file -- Its location on disk, if it has one.

If I make the solution, I’ll write it as following.

step 0: Quit all running applications
step 1: Find application file outside /Application folder by spotlight
step 2: Display found path(s) with Finder or dialog
step 3: (move application files by hand or script)

Thanks for the suggestion I will try something, but if you can post an example it would be excellent,