Skip to main content

we need to remove VPN Icon from menu bar

any idea how to achieve this via configuration profile?

 

@madhavigandhi1 It's not a Configuration Profile, but here's a script to remove the VPN menu:

#!/bin/sh

# Remove the VPN menu from the System UI Server's Menu Extras list

currentUser=$( echo "show State:/Users/ConsoleUser" | scutil | awk '/Name 😕 { print $3 }' )

runAsUser() {
currentUserID=$(id -u "$currentUser")

if [ "$currentUser" != "loginwindow" ]; then
/bin/launchctl asuser "$currentUserID" sudo -u "$currentUser" "$@"
fi
}

runAsUser /usr/libexec/PlistBuddy -c 'delete menuExtras: "/System/Library/CoreServices/Menu Extras/VPN.menu"' /Users/$currentUser/Library/Preferences/com.apple.systemuiserver.plist
runAsUser /usr/bin/killall cfprefsd
runAsUser /usr/bin/killall SystemUIServer

exit 0

 


Hi sdagley

What should the script look like if you want to add the VPN icon to the menu bar? Unfortunately, my attempts have not worked so far. Would be great if you could help here.


Hi sdagley

What should the script look like if you want to add the VPN icon to the menu bar? Unfortunately, my attempts have not worked so far. Would be great if you could help here.


This hasn't been tested but this is what I think you need to add the VPN icon:


runAsUser /usr/libexec/PlistBuddy -c 'Add menuExtras: "/System/Library/CoreServices/Menu Extras/VPN.menu" bool true' /Users/$currentUser/Library/Preferences/com.apple.systemuiserver.plist

It does appear that macOS Sonoma (and possibly other versions of macOS that have Control Center) there is additional data in the  ~/Library/Preferences/com.apple.systemuiserver.plist so that command alone may not be sufficient.


Reply