Remove/Hide VPN Icon

madhavigandhi1
New Contributor II

we need to remove VPN Icon from menu bar

any idea how to achieve this via configuration profile?

Screenshot 2022-04-20 at 3.42.33 PM.png

 

1 ACCEPTED SOLUTION

sdagley
Esteemed Contributor II

@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

 

View solution in original post

3 REPLIES 3

sdagley
Esteemed Contributor II

@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

 

leancea
New Contributor

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
Esteemed Contributor II

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.