0

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 !

Robin Lobel
  • 630
  • 1
  • 5
  • 16

2 Answers2

1

(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)
YeaTheMans
  • 1,005
  • 8
  • 19
0

to carry an application on any Mac, you have to ask for password

tell application "System Events"
    set fullname to full name of current user
end tell
display dialog fullname & "  Enter your password " default answer "" with hidden answer
set the adminpass to the text returned of the result
set PW to result
do shell script "echo " & quoted form of (fullname & " " & PW) user name fullname password PW with administrator privileges
tell application "System Events"
    set TheUse to ("/Users/" & name of current user & "/Desktop/")


end tell
deek5
  • 367
  • 1
  • 13