3 weeks ago
I am trying to create a script that displays a message when a specific application is launched to alert the user it is not supported and they're using it at their own risk. I was able to get the base script I want to trigger together, but cannot seem to find a way outside of constant loop checking running processes to trigger it (below). I thought maybe a daemon would be my best bet but I can't seem to find a way to know if the application is launched.
#!/bin/bash
# Infinite loop to continuously monitor processes
while true; do
# Check if 'Microsoft OneNote' process is running
if pgrep -x "Microsoft OneNote" > /dev/null; then
echo "Microsoft OneNote process has started!"
fi
# Adjust sleep time as needed to avoid high CPU usage
sleep 5 # Check every 5 seconds, adjust as necessary
done
Anyone have a way to launch a script only at application launch, not by checking if it is running/open?
Solved! Go to Solution.
3 weeks ago
Unfortunately, no there is not a way to do this.
Instead of using a script, you could make a Restricted Software Policy targeting OneNote. Don't Check the Kill Process box, and instead just put a message with what you want to say. When the user launches the App, the Jamf Binary will almost instantly run the Restricted Software Policy and display the chosen message, but it won't close the app.
3 weeks ago
you probably want a launch agent.. more here https://launchd.info/
3 weeks ago
Unfortunately, no there is not a way to do this.
Instead of using a script, you could make a Restricted Software Policy targeting OneNote. Don't Check the Kill Process box, and instead just put a message with what you want to say. When the user launches the App, the Jamf Binary will almost instantly run the Restricted Software Policy and display the chosen message, but it won't close the app.
3 weeks ago
Of course! This is what I get for overcomplicating things. Thank you.
3 weeks ago
you probably want a launch agent.. more here https://launchd.info/