Skip to main content
Question

Need to open app as user via Jamf Policy

  • June 22, 2021
  • 2 replies
  • 24 views

KyleEricson
Forum|alt.badge.img+17

I have tried this script but doesn't seem to work.

#!/bin/zsh

# Get the logged in user's name
CURRENT_USER=$(/bin/echo "show State:/Users/ConsoleUser" | /usr/sbin/scutil | /usr/bin/awk '/Name :/&&!/loginwindow/{print $3}')

# Get the logged in user's id
USER_ID=$(id -un $CURRENT_USER)

# Open app as user
sudo -u $USER_ID open -a 'Jamf Connect.app'

exit 0

2 replies

Forum|alt.badge.img+15
  • Esteemed Contributor
  • 719 replies
  • June 22, 2021
su -l ${CURRENT_USER} -c "open /Applications/Jamf Connect.app/"

Forum|alt.badge.img+11
  • Valued Contributor
  • 164 replies
  • May 14, 2022
su -l ${CURRENT_USER} -c "open /Applications/Jamf Connect.app/"

does not like the -c option.