AppleScript requires elevated privileges after upgrade to MacOS 12 (and now 12.1)

After upgrading to MacOS 12, Applescript seems to require elevated privileges to execute:

osascript -e 'tell app "Finder" to display dialog "Hello, World!"'

results in:

osascript: can't open default scripting component.

whereas:

sudo osascript -e 'tell app "Finder" to display dialog "Hello, World!"'

outputs:

button returned:OK

Also:

osalang -L
ascr appl cgxervdh   ()
jscr appl cgxe-v-h  JavaScript (JavaScript)
scpt appl cgxervdh  JavaScript (JavaScript)

Whereas:

sudo osalang -L
ascr appl cgxervdh  AppleScript (AppleScript.)
jscr appl cgxe-v-h  JavaScript (JavaScript)
scpt appl cgxervdh  Generic Scripting System (Transparently supports all installed OSA scripting systems.)

I have tried reinstalling the upgrade with no change of behaviour.. I'm now on 12.1, again with no change.

After upgrading to MacOS 12, Applescript seems to require elevated privileges to execute

That’s not the case. Rather, something in your user context is preventing osascript from functioning. Your use of sudo causes osascript to run in a different context, which gets around the problem. Try this:

  1. User System Preferences > Users & Groups to create a new user.

  2. Log in as that user.

  3. Run osascript there.

Based on previous discussions here on DevForums (like this and this) I’m pretty sure that’ll work.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

I haven't seen that myself, even using the finder, so it may just be that user. However, you don't need the finder for that anyway. Display Dialog is part of the standard additions so:

osascript -e 'display dialog "Hello, World!"'

works without involving the Finder.

you may also want to check various Library/ScriptingAdditions/ folders to see if there's maybe not some older third party thing causing you issues. (Adobe has caused this issue a lot for people over the years)

AppleScript requires elevated privileges after upgrade to MacOS 12 (and now 12.1)
 
 
Q