reitermarkus reitermarkus - 8 months ago 60
AppleScript Question

Application.make in JavaScript for Automation (JXA)

I'm trying to convert this existing AppleScript script:

tell application "System Events"
make login item with properties {path:"/Applications/", hidden:false"}
end tell

Here is what I have so far:

#!/usr/bin/env osascript -l JavaScript

'use strict';


function run(argv) {

var systemEvents = Application('System Events')

new: 'LoginItem',
at: systemEvents.loginItems,
withProperties: {
name: "Application",
path: "/Applications/",
hidden: false,
kind: "Programm"


I am stuck at the following line however, as I don't actually know what to pass to the
property, I think the other properties are correct.

new: 'LoginItem',

I hope someone can point me in the right direction.


Make new doesn't work in JXA.

Use theApp.TheClassName({somePropertyName: "someValue"}) to create object.

After that, use theApp.theClassNameWith_s.push(theObject) to append the object to the array


var systemEvents = Application('System Events')
logItemObj = systemEvents.LoginItem({path: "/Applications/", hidden: false})
  • Don't use kind and name, these properties are read only.