Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mac applescript - ask for administrator privileges prompt

I use applescript to launch my script with root privileges.

osascript -e "do shell script \"myscript.sh\" with administrator privileges"

This text is displayed in the prompt:

osascript wants to make changes. 
Type your password to allow this.

How can I change the name "osascript" to my executables name? Is there a way to change the icon in this prompt?

like image 486
plettix Avatar asked Jun 24 '14 09:06

plettix


People also ask

How do I run AppleScript on Mac?

In the Script Editor app on your Mac, click the Run button in the toolbar, or press Command-R, to execute the commands in your script.

How do I run AppleScript automatically?

Click Actions in the top-left corner of the Automator window, then select Utilities in the Library. Drag the Run AppleScript action into your workflow. You can edit, compile, and test your script right in the action, or you can develop your script in Script Editor.


1 Answers

If you make your AppleScript an application (in Script Editor, go File>Save as…>Type "Application"), you can then set an icon and a user-friendly name. Save the application with the name that you want to appear in the alert window (replacing "osascript). Set an icon by opening the new application's package, and replacing the applet.icns file with your own icon.

If you need to call this from the command line, then you can use the open command.

like image 74
sebthedev Avatar answered Dec 30 '22 14:12

sebthedev