Disable WiFi & WiFi menu

tdenton
Contributor

Hello

Has anyone had any success in disabling WiFi and the WiFi menu. Configuring our Monterey build for our labs environments.

Have found a script to disable WiFi but struggling to disable the WiFi menu.

Have found a few config profiles on here but can't seem to get them working. I think there for older version off OSX.

A config profile would be ideal if anyone is able to help.

 

It would need to work on both intel and M1 Imacs.

Thanks

 

 

 

12 REPLIES 12

PaulHazelden
Valued Contributor

I use these two to sort that out, but if the menu bar is set to display the status, then it still will, it will be greyed out.

Not tried a config profile for it yet. It works with 12.3.1, but as with anything Test, Test and Test again.

# Turn Off WiFi

/usr/sbin/networksetup -setairportpower airport off

# Disable the Wifi service

networksetup -setnetworkserviceenabled Wi-Fi off

When you go into the System Preferences, and Network. WiFi will be showing as inactive.
Swapping the "off" to "on" will reverse the changes.

thanks @PaulHazelden there does'nt seem to be nice way to remove menu bar.

do you know if  networksetup has a way to hide it instead?

 

From what I can work out, it isnt in networksetup. Its in com.apple.systemuiserver, but its in an array and can get messy to fix because it can be in different locations in the array.

I found some stuff on it, but from a long time ago, think High Sierra long time ago. Not sure any of that will be relevant. They were using the defaults command to then deal with the array, and then kill the systemUIServer.

I just live with it as it is. If I remember when I am logged in to the Macs, I turn it off manually. Once the service is inactive, you need an administrator to turn it back on again.

From Big Sur up it’s the com.apple.controlcenter you should be looking at.

Just run sudo -u $currentUser defaults -currentHost write com.apple.controlcenter WiFi -int 8 to hide it and 2 to show it back, either from Execute Command or a script (just set currentUser var with stat or scutil). Of course it won’t work if no one’s logged in, so account for that. If it doesn’t get you the effect immediately (it should), killall ControlCenter 👍

What would that look like on Monterey or this would work on this version of OSX also.

Same. „From Big Sur up” says it all, I suppose 😉.

Of course I’m sure someone will read this in 2030 and prove me wrong 🤣.

TDManila
New Contributor III

@PaulHazelden  Do you have the script for Ethernet as well?

Hi, Not something I have done.

networksetup -listnetworkserviceorder

Will give you the names of all of the services, in the order they are set to be used. And for me the Ethernet is called "Ethernet"

Then...

networksetup -setnetworkserviceenabled Ethernet off

Would be the command to use to disable the Ethernet connection, Put on at the end to turn it back on.

networksetup help

Will give you a full list of the commands and how to use them.

You might have to use sudo in front of the commands as some will require root access to run.

As with everything Test it several times in your setup before sending it out into production.

Thank you so much bro!

Will try this out

plegato
New Contributor II

Could you show me how you worked this out? Script or config profile. I see a lot of responses and was wondering what worked for you.

DanJ_LRSFC
Contributor III

Is there a configuration profile anywhere for com.apple.controlcenter to hide the Wi-Fi icon? I was trying with iMazing Profile Editor but it doesn't seem to support this option? Does anyone have a plist or mobileconfig they can share?

HenryOzsoy
New Contributor III

 

networksetup -setairportpower en0 off (turns off WiFi)

networksetup -setnetworkserviceenabled Wi-Fi off (disables WiFi adapter so in Control Centre it indicates its not configured)

As an admin
networksetup -setairportpower en0 on (turns on WiFi)
networksetup -setnetworkserviceenabled Wi-Fi on enables WiFi adapter