"Osascript is trying to send restricted scripting addition commands to other applications..."

Hi,

I'm using Keyboard Maestro 9.0.3 on Mojave (10.14.6, latest before Catalina). Recently, I am being prompted to enter my password whenever I want to execute a macro involving AppleScript. The message goes like so:

Osascript is trying to send restricted scripting addition commands to other applications. Enter your password to allow this.

This started recently and I cannot connect it to some event, e.g. the installation of some new application or what have you. I've tried the traditional routes like toggling permissions in Accessibility on and off, repairing permissions, to no avail.

What do you suggest I try next to solve this issue? It's quite irritating and often defeats the purpose of using macros for a good portion of everyday tasks.

P.S. Thinking further on the events preceding the problem has me wondering if (re)connecting my NAS has something to do with it, but it never caused these issues in the past.

Have you tried running your AppleScript from the Script Editor?

If so, and you get the same message, please upload your script in a Code Block.

I tried now and that's the only way it will execute the script

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

tell current application
  set mvfiles to selection
  set destFolderPath to (choose folder with prompt ¬
    "Choose Folder...")
  move mvfiles to destFolderPath
end tell

This is just one of several scripts; most if not all scripts executed from any other application that Script Editor falls prey to the same prompt. Substituting the tell to a specific application like Finder doesn't help.

Try running your script using osascript in the Terminal and see if you get the same result.

A search for this exact error across the net does not find anyone else with it, so that doesn't help narrow it down to any specific application.

Other than maybe an application with a wayward osax (AppleScript extension), I'm don't really have any ideas.

Your not using proper AppleScript. The proper form is:
tell application "appName"

From https://macscripter.net/viewtopic.php?pid=154268#p154268

current application is the current AppleScript environment which runs the script, not the frontmost application

For more info see The AppleScript Tell Block -- MacOSXAutomation.com

I've written hundreds of AppleScripts for KM like this that always work just fine:

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

tell application "Finder"
  set mvfiles to selection
  set destFolderPath to (choose folder with prompt ¬
    "Choose Folder...")
  move mvfiles to destFolderPath
end tell

I just tested this in Script Debugger and KM, and it works fine.

MACRO:   Test AppleScript

~~~ VER: 1.0    2019-10-17 ~~~
Requires: KM 8.2.4+   macOS 10.11 (El Capitan)+
(Macro was written & tested using KM 9.0+ on macOS 10.14.5 (Mojave))

DOWNLOAD Macro File:

Test AppleScript .kmmacros
Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.


If this script/macro fails for you, then there is something wrong on your Mac, maybe as @peternlewis suggested, a corrupt Scripting Addition (OSAX), although as of macOS Mojave Apple does not allow or use user provided Scripting Additions.

As always, start with the simple troubleshooting. Do each, and test after each step.

  1. Restart KM Engine and Editor app
  2. Restart your Mac
  3. Start your mac in Safe mode .

Turned out having StandardAdditions.osax in two locations was causing the interference. Kept the one in Sys/Lib and removed the other. Problem solved.