How to prevent the "Your Script is not allowed assistive access" error window?

Could anybody explain how to prevent the “Your Script is not allowed assistive access” error window when running a compiled script?

Screenshot 2025-03-17 at 9.41.36 PM copy

Below, at the very bottom of this post, is a script from a recent discussion. If I compile it using osacompile, like

osacompile -o list-view.app list-view.applescript

then its name under System Settings > Privacy & Security > Accessibility is simply applet, which is not very descriptive and convenient, of course. But at least, if I turn it on, the script works, and the error window doesn’t appear.

Okay, but because I really don’t like my applet to be called just applet, I searched the internet for how it can be changed to something meaningful. I tried to edit Info.plist using

plutil -replace CFBundleName -string "New Applet Name" "/path/to/applet.app/Contents/Info.plist"

but this didn’t help. Another solution that is often suggested is to open the script in Script Editor and export it as application manually: File > Export > File Format = Application. And yes, it worked!

When I opened System Settings > Privacy & Security > Accessibility, my applet was named the same as the file itself, list-view, which is fine.

But!.. For some reason, at least for me (macOS 15.3.2), turning it on, contrary of as we turned on applet, doesn’t prevent the “Your Script is not allowed assistive access” window to appear!

Screenshot 2025-03-17 at 9.41.36 PM copy

I tried to run the script after removing list-view from there (that is: 1. remove list-view from the System Settings > Privacy & Security > Accessibility list → 2. run the script, so that list-view will appear there again, turned off → 3. turn it on), but this didn’t help, the error window still appears.

Do you have the same problem? Yes, no? Please don’t ignore this part, thanks! :slight_smile: And how it can be fixed or maybe there is a workaround which I’m not aware of?

In its current state it seems that scripts that are exported from Script Editor as applications are broken in some way?

Okay, and now the script itself:

global mediumDelay
global shortDelay
global longDelay
set mediumDelay to 1 -- edit as necessary
set shortDelay to 0.5 -- edit as necessary
set longDelay to 2 -- edit as necessary

tell application "Finder"
  set targetFolder to target of front Finder window
  try
    set theSubfolders to every folder of the entire contents of targetFolder
    if class of theSubfolders is not list then set theSubfolders to theSubfolders as list
  on error
    set theSubfolders to {}
  end try
end tell

set theFolders to (targetFolder as list) & theSubfolders

-- optionally
set theSubfoldersMaxNumber to 10 -- edit as desired
if (count theSubfolders) is greater than theSubfoldersMaxNumber then
  display dialog "This script will only reset" & space & theSubfoldersMaxNumber & space & "or fewer subfolders" buttons {"OK"} cancel button 1 default button 1
end if

repeat with aFolder in theFolders
  tell application "Finder" to set the target of Finder window 1 to aFolder
  resetFinderWindow()
  delay mediumDelay -- edit as necessary
end repeat

tell application "Finder"
  set target of front Finder window to container of targetFolder -- previous...
  set target of front Finder window to targetFolder -- ...and back
end tell

on resetFinderWindow()
  tell application "Finder"
    tell front Finder window
      set current view to list view
    end tell
    
    activate
    delay mediumDelay -- edit as necessary
    
    tell application "System Events" to tell process "Finder"
      tell menu item "Show View Options" of menu of menu bar item "View" of menu bar 1 to if exists then click
      delay mediumDelay -- edit as necessary
      repeat with boxName in {"Comments", "Date Added", "Date Created", "Date Last Opened", "Date Modified", "Kind", "Size", "Tags", "Version"}
        if boxName is in {"Date Modified", "Kind", "Size"} then -- edit as desired
          tell checkbox boxName of group 1 of window 1 to if value is 0 then click
        else
          tell checkbox boxName of group 1 of window 1 to if value is 1 then click
        end if
      end repeat
      delay mediumDelay -- edit as necessary
      tell menu item "Hide View Options" of menu of menu bar item "View" of menu bar 1 to if exists then click
    end tell
    
    tell front Finder window
      set options to its list view options
    end tell
    
    tell options -- edit as desired
      --set properties to {calculates folder sizes:false, shows icon preview:false, icon size:small, text size:14, sort column:name column, uses relative dates:true} -- optionally
      set properties of column name column to {index:1, sort direction:normal, width:100}
      set properties of column comment column to {index:2, sort direction:normal, width:1}
      set properties of column creation date column to {index:3, sort direction:normal, width:1}
      set properties of column kind column to {index:4, sort direction:normal, width:1}
      set properties of column label column to {index:5, sort direction:normal, width:1}
      set properties of column modification date column to {index:6, sort direction:normal, width:1}
      set properties of column size column to {index:7, sort direction:normal, width:1}
      set properties of column version column to {index:8, sort direction:normal, width:1}
    end tell
  end tell
end resetFinderWindow

john202307. The issue you note has been around for several years, and I’ve never seen a solution that works in every instance. Unfortunately, with every new version of macOS, this issue seems to get worse. I’m now on Sequoia.

I saved your script with Script Editor (and separately Script Debugger) as an app. I then gave it Accessibility and Full Disk access permissions, but the app would not run. I toggled the permissions on and off, and that did not help.

That I’m aware of, the only workaround is the one you mention, which is to create the app with osacompile. As you note, System Events’ Privacy & Security then shows the app as “applet”, which is pretty kludgey, but at least the app runs.

Other solutions are to save the script as a script (i.e. scpt) and to run it by some other method. The simplest is to use the Script Menu that is enabled in Script Editor. There are also various utilities (such as FastScripts) that can be used to run the script.

1 Like

Don’t you know how to make the plutil method work after compiling the script using osacompile?

plutil -replace CFBundleName -string "New Applet Name" "/path/to/applet.app/Contents/Info.plist"

It successfully changes the “Bundle name” string in Info.plist, but when I try to run the script, macOS complains the script is not authorized to send events to Finder:

Screenshot 2025-03-17 at 11.47.05 PM

In my testing, the app created by osacompile already had the correct bundle name (which was “Test Script”). The bundle executable was “applet”. It’s only a guess, but I suspect that editing the plist is going to break the app’s Accessibility permission. Perhaps there’s some way around this.

1 Like