Skip to main content

App works find with ARD but is mostly failing on all machines the policy is scoped too. Running High Sierra, any info would be helpful. Thanks.

osascript -e 'tell application "System Events" to make login item at end with properties {path:"/Applications/myapp.app", hidden:false}'

Trying to add item to login item list.

That might be a per user setting.


ARD can run scripts as the logged in user. Jamf can't, unless you specify the user in your script.


how do i specify user in this script, thanks


Try this:

#!/bin/bash
loggedInUser=$(/usr/bin/python -c 'from SystemConfiguration import SCDynamicStoreCopyConsoleUser; import sys; username = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None])[0]; username = [username,""][username in [u"loginwindow", None, u""]]; sys.stdout.write(username + "
");')

echo "Adding login item for $loggedInUser"
sudo su - "$loggedInUser" -c "osascript -e 'tell application "System Events" to make login item at end with properties {path:"/Applications/Firefox.app", name:"Firefox", hidden:false}'"

exit 0