Skip to main content

I wanted to make a popup window that users had to click on to acknowledge they were getting an update that would close their open application.

I created a notifyScript , a notifyPolicy, and a updatePolicy.

notifyPolicy is set to enabled, recurring check-in, automatically rerun, on next.

notifyPolicy is set to enabled. notifyPolicy passes the name of updatePolicy into notifyScript as an argument

notifyScript uses updatePolicy name as a custom event trigger to call update Policy

When notifyPolicy runs, i get the following:

"No policies were found for the "updatePolicy" trigger.

Where am i going wrong?

Try this script, which was modified to use jamfHelper. See if you get what you want.

#!/bin/sh

# uncomment the next line to enable debugging
#set -x

## Parameters for new software version
appPath="$4" # Path to application, escape spaces, no quotes
appName="$5" # Name of App
newVersion="$6" # target App Version
policyTrigger="$7" # name of install policy to be triggered

jamfHelperPath="/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper"

# get the currently logged in user
currentUser=$( echo "show State:/Users/ConsoleUser" | scutil | awk '/Name 😕 { print $3 }' )

# get version of installed appName
version=$( /usr/bin/defaults read "$appPath/Contents/Info" CFBundleShortVersionString )

# Get the application's icon icns path
appIcon=$(/usr/bin/defaults read "$appPath/Contents/Info" CFBundleIconFile)

## path to icon for dialog
iconPath="$appPath/Contents/Resources/$appIcon"

# global check if there is a user logged in
if [ -z "$currentUser" -o "$currentUser" = "loginwindow" ]; then
echo "no user logged in, cannot proceed"
exit 1
fi

# now we know a user is logged in

# main code starts here
if [[ $version != $newVersion ]]
then
notifyText="$appName is outdated. Please quit $appName, then click OK to Update."
"$jamfHelperPath" -windowType utility -description "$notifyText" -button1 "OK" -defaultButton 1 -icon "$appIcon"
# pgrep "$appName" | xargs kill -15
# /usr/local/bin/jamf policy -event "$policyTrigger"
else
echo "*** $appName versions match "
exit 0
fi

exit 0

So, At first I was excited, because as soon as I tied this updateNotify2 script to the updateNotify Workspace policy, I got my popup-window!  Didn't get the icon, just a blank space, but that is so far down the list of priorities that it has become irrelivant!

 

I got super excited for a second, but then I saw that the actual update didn't kick off. I was confused, since i had cloned the previous updateNotify policy into the new one.

Then I saw that the lines for doing the actual custom trigger had been commented out!  Two successful test later and I'm feeling way more confident about proceeding.

Thanks for your help!


So, At first I was excited, because as soon as I tied this updateNotify2 script to the updateNotify Workspace policy, I got my popup-window!  Didn't get the icon, just a blank space, but that is so far down the list of priorities that it has become irrelivant!

 

I got super excited for a second, but then I saw that the actual update didn't kick off. I was confused, since i had cloned the previous updateNotify policy into the new one.

Then I saw that the lines for doing the actual custom trigger had been commented out!  Two successful test later and I'm feeling way more confident about proceeding.

Thanks for your help!


Ah! My bad! I forgot I commented those lines out when I ran a quick test on the script before posting it. 
Glad you figured that out though! 

 

As for the icon not showing up, that was my somewhat feeble attempt to get the icon of the app you’re looking to update to show up, but it’s not a guarantee to work on all apps. It’s probably best you swap in your own icon, like a company logo maybe on disk somewhere. Just add the path to the icon file or image after the -icon flag in the script. 


@mm2270 - thanks for setting me right, again. 🙂 I guess I didn't read far enough through Armin's post, and I've only ever used that command for launchctl stuff. Regardless, I should have suggested moving away from AppleScript in favor of one of the solutions you mentioned. I know better.


Thank you so much for jumping in and helping, @stevewood! Its super appreciated on my end just getting a response at all!


A retail giant, Eternal Wigs holds a significant position in the American marketplace. Renowned for its extensive network, Eternal Wigs operates across more than 34 states in the United States, encompassing a diverse range of retail offerings.

For more information click here.

<a href="https://eternalwigs.com/">Eternal Wigs</a>


Reply