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)