Set admin privileges once in a script with a repeat loop?

This has probably been discussed before. If not, please read on.

I have two or three droplets using this line

"do shell script "rm -rfP "

followed by a variable that references a file or folder dropped on the icon, in POSIX path form first then quoted form. I recently “beefed up” both a single-file droplet and single-folder droplet to use administrator privileges. Where I’m having trouble is setting these for versions (for want of a better word) of the droplets written to delete more than one file. I would like to know if there is a way an administrator password prompt can be displayed once and the admin privileges applied to deletion of all the files. Otherwise users (myself included) will be asked for our password with every file targeted for deletion.

Here’s the code from the last attempt at a many-file deletion droplet with admin privs:

on open the_Items set Moscow to 0 repeat with an_item in the_Items set Moscow to Moscow + 1 set scrood to POSIX path of an_item set scrood_double to (quoted form of scrood) set theText01 to (do shell script "rm -fP " & scrood_double & "" with administrator privileges and password) end repeat end open
I presume it’s because the “do shell script” is inside the “repeat” loop that it’s prompting for a pw with every deletion attempt. But I have Google’d myself blue in the face looking for somewhere else to put the call for a password where it would “stick” while the actual deletion tasks are performed. I could write an initial repeat loop that had do script “chmod 666” and a variable reference (as above) to the file, but to sudo that would be to run into the same problem – a password prompt for every file dropped on the applet. So I’m back to asking: How does one set admin privs ahead of repeat loops so they’ll stay valid while the set task(s) of the scripts are attempted or completed?

Hope I was clear enough in what I was looking for.

Silversleeves

Model: PowerMac G4 QS 1.25 Dual MDD
AppleScript: 1.9.3
Browser: Firefox 1.5.0.8
Operating System: Mac OS X (10.3.9)

Hi Silversleeves,

Ask for the password before the loop.

local p

display dialog “Enter password:” default answer “”
set p to text returned of result
repeat
do shell script “whatever” with administrator privileges password p
end repeat

gl,

Thanks kel.

Silversleeves

Hi Ned

Sorry to stick my nose in here…
i use this to delete files or folders it hasn’t failed me on anything has of yet, and not
prompted me for a password either.

on open theitemtodelete
	display alert "If you click Delete its gone forever!" message "There's absolutely no chance of getting it back!!" buttons {"Too Scared!..", "Delete..."} default button 1 as warning
	if the result is {button returned:"Too Scared!.."} then
		display dialog "Chicken..." buttons {"i'm a Big Girl"} default button 1
		return
	else
		repeat with theItem in theitemtodelete
			set deletethis to (POSIX path of theItem) as string
			do shell script "rm -R " & quoted form of deletethis
		end repeat
	end if
end open