Posted on 12-26-2019 09:40 AM
I am looking ultimately to launch an application for every user that logs into a Mac. I tried running a script and the policy log shows it ran with an exit code of 0.
#!/bin/bash
open -a /Applications/myapp.app
exit 0
I can make that script on the client device and execute it and it works. Any ideas as to what I am missing?
Posted on 12-26-2019 01:18 PM
Jamf scripts run as root. You probably want your open command to run as the logged in user.
loggedInUser=$( scutil <<< "show State:/Users/ConsoleUser" | awk '/Name :/ && ! /loginwindow/ { print $3 }' )
su -l $loggedInUser -c "open /Applications/myapp.app/"
Another issue you're probably running into is that jamf login scripts are usually going to run before the user's login environment has fully loaded. Look into Launch Agents. Launch Agents load when the user environment loads.
Posted on 12-28-2019 06:45 AM
This is really something that a LaunchAgent should be used for.
LaunchAgents & LaunchDaemons are important things to learn when it comes to macOS administration.
As such, have a look at: https://www.launchd.info