plettix
plettix

Reputation: 143

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?

Upvotes: 6

Views: 5548

Answers (1)

sebthedev
sebthedev

Reputation: 288

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.

Upvotes: 4

Related Questions