Skip to main content
Question

Script works on ARD, spotty with Jamf

  • August 13, 2018
  • 4 replies
  • 9 views

Forum|alt.badge.img+5

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

Forum|alt.badge.img+18
  • Contributor
  • 475 replies
  • August 13, 2018

That might be a per user setting.


Forum|alt.badge.img+9
  • Valued Contributor
  • 138 replies
  • August 14, 2018

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


Forum|alt.badge.img+5
  • Author
  • Contributor
  • 14 replies
  • August 16, 2018

how do i specify user in this script, thanks


Forum|alt.badge.img+18
  • Contributor
  • 475 replies
  • August 16, 2018

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