Skip to main content
Solved

Remove/Hide VPN Icon

  • April 20, 2022
  • 3 replies
  • 27 views

Forum|alt.badge.img+3

we need to remove VPN Icon from menu bar

any idea how to achieve this via configuration profile?

 

Best answer by sdagley

@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

 

3 replies

sdagley
Forum|alt.badge.img+25
  • Jamf Heroes
  • Answer
  • April 20, 2022

@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

 


Forum|alt.badge.img+3
  • New Contributor
  • March 6, 2024

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.


sdagley
Forum|alt.badge.img+25
  • Jamf Heroes
  • March 6, 2024

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.