Script works on ARD, spotty with Jamf

tcarlson
New Contributor III

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.

4 REPLIES 4

ryan_ball
Valued Contributor

That might be a per user setting.

barnesaw
Contributor III

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

tcarlson
New Contributor III

how do i specify user in this script, thanks

ryan_ball
Valued Contributor

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