Posted on 02-28-2024 07:56 AM
We are going all online for the ACT this year and we have to use Pearson's TestNav app in order for the students to test on their school-issued Macbook Airs. They are running MacOS Ventura (or Sonoma for those who upgraded before we had the chance to block updates).The TestNav documentation says that we need to disable all of the notifications for the students while they're taking tests. I haven't been able to find a reliable way to do this. I found some scripts but they may be outdated because they keep throwing errors. Does anyone have a solution to this? I need to send a command through Jamf Pro to all of the student Macbooks to turn off notifications before the test then send another command to re-enable them after the test. Would forcing them into Focus mode do the trick?
Here's the script I found. I modified it slightly by replacing "unload" with "bootout" using the syntax I found here:
https://joelsenders.wordpress.com/2019/03/14/dear-launchctl-were-all-using-you-wrong/
Both old and new commands are at the end of the script. I just comment out the one I don't want to test.
The errors I get are as follows:
If I use "unload" it tells me to use "bootout" instead
5: Input/output error
The script (I found this either on Jamf Nation or on GitHub after a Google search but I don't remember where):
#!/bin/sh
# Variable and function declarations
export PATH=/usr/bin:/bin:/usr/sbin:/sbin
# Get the currently logged in user
currentUser=$( echo "show State:/Users/ConsoleUser" | scutil | awk '/Name :/ { print $3 }' )
# 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
# Get the current user's UID
uid=$(id -u "$currentUser")
# Convenience function to run a command as the current user
runAsUser() {
if [ "$currentUser" != "loginwindow" ]; then
launchctl asuser "$uid" sudo -u "$currentUser" "$@"
else
echo "no user logged in"
# uncomment the exit command
# to make the function exit with an error when no user is logged in
# exit 1
fi
}
# Disable Notification Center
# Old command
# runAsUser launchctl unload -w /System/Library/LaunchAgents/com.apple.notificationcenterui.plist
#New command
runAsUser launchctl bootout gui/$uid /System/Library/LaunchAgents/com.apple.notificationcenterui.plist
exit 0
Posted on 02-28-2024 08:00 AM
can you not use a config profile with the notifications payload?
Posted on 02-28-2024 08:39 AM
It looks like the Notifications payload only lets you disable/enable notifications for specific apps. I want to disable all notifications. Is there another payload that'll do this without interfering with the config profile that has the restrictions?
02-28-2024 09:00 AM - edited 02-28-2024 09:06 AM
runAsUser has launchctl asuser "$uid" sudo -u "$currentUser" "$@"
so new command should be:
runAsUser bootout... etc
removing the launchctl ?
EDIT: use exit $? after the command to get the correct exit code..
Posted on 02-28-2024 11:16 AM
Bootout is part of launchctl, right? Bootout by itself doesn't work.
02-28-2024 11:27 AM - edited 02-28-2024 11:34 AM
EDIT: runASuser just reeds the bootout gui/$uid /System/Library/LaunchAgents/com.apple.notificationcenterui.plist
Posted on 05-14-2024 04:07 PM
Did you solve this issue? We have nearly the exact same thing, with excessive alerts appearing onscreen for student users upon login. Thank you!