How do I trash files in the main apps folder if I'm not admin?

I’m desperate and hoping someone can help.

I’m writing an AppleScript that I want to run as a “preflight” sort of thing to determine if a folder already exists in the main applications folder and if so to trash it before I reinstall it. Sounds simple enough, right?

The problem is that I need to run this logged in as the user and not the admin of the machine and for some reason when I try this:

do shell script “sudo -s rmdir -p /Applications/MyFolder” password “ADMIN PASSWORD” with administrator privileges

I’m not able to get it to work. I get a password error that I’ve discovered basically is telling me that I’m not the admin or the user isn’t on the sudoers list which the admin is, but of course the user isn’t.

I don’t want to modify the sudoers file if possible. I just want to run this momentarily to have it trash one folder and move on.

Any ideas? Maybe there’s an easier way? I’m using OS X 10.3.9

Thanks in advance for any and all help!!

AppleScript: 1.9.3
Browser: Safari 312.5
Operating System: Mac OS X (10.3.9)

You could do this in AppleScript using the Finder (which can empty the trash, but you’d have to see what was in it first). You could also just put up a dialog box asking for the user’s password (using the new “hidden answer” property).

The problem is that the user doesn’t have rights to trash anything from the main applications folder. The Finder needs the admin’s username and password here to trash this folder so prompting for the user password won’t work.

What is the “hidden answer” property?

The hidden answer displays a text entry box that will only display the character “¢” no matter what is entered, but it returns whatever was entered. Run this:

set theText to text returned of (display dialog "What is the word you don't want to have show here" default answer "Hidden Word" with hidden answer)

With respect to your direct problem - it seems that you’ve made it impossible to do what you want to in a direct way.

If you’re writing an application installer of some sort, I suggest you start by learning PackageMaker as it’s the standard solution for handling non drag-n-drop installs:

http://developer.apple.com/documentation/DeveloperTools/Conceptual/SoftwareDistribution/index.html

HTH