Mac applescript - ask for administrator privileges prompt
Asked Answered
O

1

6

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?

Overage answered 24/6, 2014 at 9:24 Comment(2)
Have you found any solution yet?Onstad
@Onstad no I don't use it anymore. But the marked answer would be a good workaround I guessOverage
D
4

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.

Drongo answered 9/11, 2014 at 0:15 Comment(1)
This worked great for changing the name and application icon, but is there any way to show the app icon next to the lock that appears on the privileges elevation prompt? For some reason, I only get the lock icon by itself.Climatology

© 2022 - 2024 — McMap. All rights reserved.