Administrator priviliges in AS

Hey!

I’m creating an uninstall script for an application that has 3 files owned by system.

Using a finder tell to move the files to the trash prompts for the administrator password for EACH file. Very annoying.

So I tried this:


do shell script "mv " & (quoted form of (POSIX path of ((path to internet plugins from user domain as Unicode text))) & "the.file ~/.Trash") with administrator privileges

The shell will keep the entered password for a a limited time, thus only prompting once for the 3 moves. However, the move will only execute if the said file doesn’t already exist in the trash. And I certainly don’t want to script emptying the user’s trash.

Is there a way to get this smooth and clean?

Or is there a better way to temporary verify and store the entered password for use with all 3 file operations?

Love and kisses,
O

You could test for the existence of the file in the trash:

set pathtotrash to (path to trash folder as text)
try
	set x to pathtotrash & "test1.txt" as alias
	-- don't do shell script
on error
	display dialog "File not found."
	-- do shell script
end try

What code are you using for this?

I don’t have the exact code in front of me right now, but it’s DEAD simple, like:


tell application "Finder" to move file theFile to trash

Works well, but like I said it asks for the password for EACH file not owned by the user.

O

Thanks for the help cwtospam! That’s a great idea.

Love,
O