user3767622 user3767622 - 1 year ago 90
AppleScript Question

sudo an application asking the user with a dialog?

I'd like to run an OSX application with admin privileges, so the user would be asked first for his admin log/pass.
Is there a bash command or an applescript command that would allow me to do that ?

Sort of a sudo command but with a graphic dialog shown to the user, similar to what the Finder shows when asking permission to write files in restricted folders.

thanks !

Answer Source

(if by OSX application are you talking about the applescript one?)

In applescript, you can display a dialog that finder displays for the users login and password but this will not tell you the password, it will basically run a shell script as sudo:

do shell script "myadminshellcommand arguments" with administrator privileges

By adding "with administrator privileges" you are telling AppleScript to run a shell script in sudo with the users password

(Don't add sudo to the command)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download