Skip to main content
Question

Jamf Prompt to quit application script

  • July 1, 2019
  • 1 reply
  • 6 views

Forum|alt.badge.img+8

I am looking for a quite "simple" script that prompt the user to close an application

Like with Adobe Remote updater it can update applications, when they are closed. So Would like a script that checks if appliation is open. If it is, it prompt the user to close it and afterwards the adobe remote updater can run

But can of course also work with other applications like Office etc

Do anyone has something they want to share? I found some but mostly are with cocoa, that I prefer not to use as it is getting legacy as I can read

1 reply

Forum|alt.badge.img+8

Actually found this what I am searching for

1#!/bin/bash
2
3
4export PATH="/usr/sbin:$PATH"
5
6JAMFHELPER="/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper"
7
8MESSAGE="There is a pending Microsoft Office security update.
9Click Close button to quit Office Application button below to.
10
11NOTE Save your work first
12
13
14Click Cancel to re-try in one hour."
15
16# Determine if Outlook is running
17IsOutlookRunning=$(pgrep -l "Microsoft Outlook")
18
19if [ "$IsOutlookRunning" ] ; then
20 echo "Detected running Outlook instance, prompting user to quit and upgrade"
21
22 # Get the user's selection
23 result=$("$JAMFHELPER" -windowType hud
24 -title "Microsoft Updates Required"
25 -heading "Microsoft Office Applications"
26 -description "$MESSAGE"
27 -icon "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertNoteIcon.icns"
28 -button1 "Cancel"
29 -button2 "Close all Office Applications")
30
31 echo "User choice: $result"
32
33 if [ "$result" == "2" ]; then
34 osascript -e 'quit app "Microsoft Outlook"'
35 echo "Clicked OK, time to quit Outlook!"
36 jamf policy -trigger InstallCachedOutlook
37 exit 0
38 else
39 echo "User chose Cancel"
40 exit 1
41 fi
42else
43 echo "Outlook is not running, proceeding with upgrade"
44 jamf policy -trigger InstallCachedAcrobat
45 exit 0
46fi

Is there a way to build in that it closes more application without I have to make a script for each office application. And also, Can I rezise the button size as it is to small to contain all text on button 2


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings