How to rename osascript in the administrator privileges dialog?
Solution 1:
I found a much better way of doing this, by digging through the Applescript doc on the Apple Developer's Site. I found this release note for Applescript in MacOS 10.10
It says:
do shell script can now specify a custom prompt to use in the password dialog. [15194980]
However, it neglects to say how you can do that. After some guesswork, I figured out that there's a prompt
clause that lets you replace osascript wants to make changes...
with whatever you want when using do shell script...with administrator privileges
in a script invoked by osascript
. For example:
osascript -e 'do shell script "ls -l" with prompt "The Great And Powerful OZ " with administrator privileges'
generates a dialog box that looks like:
I hope this helps someone.
Solution 2:
The above methods all require administrator privileges in the first place, but if you are trying to do this as part of a bash script you want to distribute without requiring administrative privileges or extra setup, you could do something like the following:
TMP=$(mktemp -d)
pushd "$TMP" > /dev/null 2>&1
/usr/bin/osacompile -e 'do shell script "echo hello args 2>&1 etc" with administrator privileges' -o 'My Cool Name.app'
'My Cool Name.app/Contents/MacOS/applet'
popd
rm -rf "$TMP"
This will create a temporary directory, compile the script as an applet, execute it and then delete the temporary directory and applet.