How to you active the Script Menu Bar with AppleScript

applescriptmenu barscript

In AppleScript if you want to show the Script Menu in the menu bar you have to:

  1. Click Applications
  2. Scroll down and click Utilities
  3. Click Script Editor (this was called AppleScript Editor in older OS X
    versions)
  4. Click the “Script Editor” menu item, then click “Preferences…”
  5. On the Preferences dialog click “Show Script menu in menu bar”
  6. If it isn’t selected, you’ll want to enable the “Show Computer scripts”
    option

but is there a file in system that I can target to activate this in a script? Trying to build an installer that will turn this on when if not active but I'm having issues trying to find where in the system I can hit this. Dont mind a do shell but prefer not to use Automator.

Best Answer

10.13 (High Sierra) and before

If you do not want to have to go through Script Editor > Preferences > General to check the
[ ] Show Script menu in menu bar check box, then here is one way of enabling the Script Menu using AppleScript:

tell application "System Events"
    if not (script menu enabled) then
        tell current application
            do shell script "open '/System/Library/CoreServices/Menu Extras/Script Menu.menu'"
        end tell
    end if
end tell

You could just use:

do shell script "open '/System/Library/CoreServices/Menu Extras/Script Menu.menu'"

However, since System Events has a script menu enabled property, it makes sense to check whether or not it's enabled first. Either way though, opening the target file loads the Script Menu and checks the [√] Show Script menu in menu bar check box in: Script Editor > Preferences > General

Also, from Terminal, you could just run:

open '/System/Library/CoreServices/Menu Extras/Script Menu.menu'

Opening the target file in any manner shown accomplishes the goal.

By the way, when the Script Menu is enabled the target plist file is:

com.apple.systemuiserver.plist

The key is a Boolean and is NSStatusItem Visible com.apple.scriptmenu, and will also have an element in the menuExtras Array as a String holding the pathname of the item.

Note that the information above was gathered under macOS 10.13.5.


10.14 (Mojave) and up

The script menu has been upgraded into a full-fledged application, instead of a .menu file. It is now located at /System/Library/CoreServices/Script Menu.app.

To activate it on 10.14+, the terminal/shell command changes to:

open '/System/Library/CoreServices/Script Menu.app'