Category filter
Script to hide the VPN icon from the menu bar on Mac
The menu bar on macOS devices makes it easy to access system settings and network settings like VPN, Wi-Fi, battery options, and much more. The VPN icon allows the users to connect to a VPN network without having to open the Networks tab from System Preferences. This document provides a bash script to remove the VPN icon from macOS devices. Admins can remotely execute the script through the Execute Custom Script option in Hexnode UEM.
Scripting Language – Bash
File extension – .sh
Remove the VPN icon from the menu bar
The delete
command will delete the VPN.menu file in the path /System/Library/CoreServices/Menu Extras/ of the current user.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
#!/bin/sh 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 |