Posted on 04-26-2024 07:40 AM
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.
Posted on 04-26-2024 08:03 AM
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.
Posted on 04-26-2024 08:07 AM
you probably want a launch agent.. more here https://launchd.info/
Posted on 04-26-2024 08:03 AM
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.
Posted on 04-26-2024 08:06 AM
Of course! This is what I get for overcomplicating things. Thank you.
Posted on 04-26-2024 08:07 AM
you probably want a launch agent.. more here https://launchd.info/