Remove unwanted networkservice

tkimpton
Valued Contributor II

Hi guys

For security reason i am trying to remove the Wi-Fi network service from Workstations.

If i do it manually in the Network System Pref pane and hit the minus, then it goes away.

If i try this in terminal

networksetup -removenetworkservice Wi-Fi

I get the error

You cannot remove Wi-Fi because there aren't any other network services on Wi-Fi.

Anyone know how i can remove it?

I know i can use this to disable it /usr/sbin/networksetup -setnetworkserviceenabled

but i have a separate script that sets the proxy for every interface and it seems the script cannot set proxy setting for a disabled network interface and it is causing errors.

2 REPLIES 2

mm2270
Legendary Contributor III

The man page for networksetup actually states this for the -removenetworkservice command:

Use this command to delete a network service <networkservice>.
**You cannot use this command to delete the last remaining service for a hardware port.** To do so, you use the -setnetworkserviceenabled command

It sounds like that's what the error you're getting is telling you.

tkimpton
Valued Contributor II

Yep, thanks Mike but like I said I already new that and didn't know of a better approach or what others did.

I decided to add to part of the proxy script to

1.detect if Wi-Fi was disabled to then reenable it

  1. Do the proxy stuff (thanks Ben Toms)

  2. Disable Wi-Fi again if its not a Laptop