Script no running as Application

Hello All,

I have created a script that will run an Entourage Identity backup whenever the user runs the app. Just wondering if anyone knows why this script will run fine in Script Editor but when I save and run it as an Application it errors. Maybe due to the do shell scripts? Any help at all would be much appreciated.


on run
	try
		set archiveFolder to do shell script "echo ~/Documents/Email\\ Backups"
		tell application "Microsoft Entourage"
			quit
		end tell
		tell application "Finder"
			activate
              end tell
		if exists archiveFolder then
			--do nothing
		else
			do shell script "mkdir ~/Documents/Email\\ Backups"
		end if
		do shell script "cp -r ~/Documents/Microsoft\\ User\\ Data/Office\\ 2004\\ Identities/Main\\ Identity/ ~/Documents/Email\\ Backups/"
		display dialog "Your Entourage Database has been backed up successfully!" buttons {"OK"}
	on error
		display dialog "Your Entourage Database backup has failed!" buttons {"OK"}
	end try
end run

Hi,

the line

if exists archiveFolder then

can’t work as expected, because you’re testing if a POSIX path exists, not the folder

try this:

try
    set archiveFolder to (path to documents folder as Unicode text) & "Email Backups"
    quit application "Microsoft Entourage"
    try
        archiveFolder as alias
    on error
        do shell script "mkdir " & quoted form of POSIX path of archiveFolder
    end try
    do shell script "cp -r ~/Documents/Microsoft\\ User\\ Data/Office\\ 2004\\ Identities/Main\\ Identity/ ~/Documents/Email\\ Backups/"
    display dialog "Your Entourage Database has been backed up successfully!" buttons {"OK"}
on error
    display dialog "Your Entourage Database backup has failed!" buttons {"OK"}
end try

Notes: the explicit run handler is not needed
Also the Finder is not needed