суббота, 29 марта 2014 г.

Automatical prompting admin privileges launching an application on Mac os

If your application requires admin privileges and you don't want the user run it from command line with sudo then you can use Apple script to achieve it
First create an apple dropplet with the code below
on run
on run
 set appAlias to POSIX path of (path to resource "CamelAudioInstaller.app")
 set cmnd to appAlias & "Contents/MacOS/CamelAudioInstaller"
 
 #display dialog "You're going to launch the app without parameters" & cmnd buttons {"Ok"}
 do shell script cmnd with administrator privileges
end run
on open this_item
 set csPath to POSIX path of this_item
 set appAlias to POSIX path of (path to resource "CamelAudioInstaller.app")
 set cmnd to appAlias & "Contents/MacOS/CamelAudioInstaller " & csPath
 
 #display dialog "You're going to launch " & cmnd buttons {"Ok"}
 do shell script cmnd with administrator privileges
end open

Now after you double click the droplet you'll get the next


Комментариев нет :