Thanks for sharing the video đź‘Ť
Hmmmmm....
I set up and ran the two scripts like in your video to compare and apart from you sharing ethernet (and me sharing Wifi) it looks the same. I see that with the "off" script you also have the network interface (ethernet) disabled like I have wifi disabled (instead of just turned off), so that's obviously how it should work.
With that out of the way I tried something new: opening up a Terminal window while having the Network system preference window open I first entered this:
Then I tried the following command which resulted in this:
and finally I repeated the "on" command. This resulted once again in "Wifi off".
So the command switches between wifi OFF and wifi DISABLED, but not wifi ON.
I would expect the "off" command to work as the "on" command does now (wifi=off) and there must be some command for turning it on. Confusing.
I'll search to see if I can find other options for "networksetup -setnetworkserviceenabled".
UPDATE: aha! I found some information here which I tested working:
turns wifi ON
and
turns wifi OFF.
So I'm going to try that in the scripts and see if I get it all working.
..... testing.....
The "on" script almost works with the new wifi command, but while it does enable wifi it doesn't share via wifi but looks for a network instead. Here's the updated script, and I'm wondering what the line in bold does and if it has something to do with it not quite working:
The "off" script appears to work (it switches off wifi and network sharing) -I tried it after "manually" enabling wifi sharing. But as it also has the same "NAT: Enabled" command I can't say for sure if it too needs some tweaking.
Hmmmmm....
I set up and ran the two scripts like in your video to compare and apart from you sharing ethernet (and me sharing Wifi) it looks the same. I see that with the "off" script you also have the network interface (ethernet) disabled like I have wifi disabled (instead of just turned off), so that's obviously how it should work.
With that out of the way I tried something new: opening up a Terminal window while having the Network system preference window open I first entered this:
Code:
networksetup -setnetworkserviceenabled Wi-Fi on
Then I tried the following command which resulted in this:
Code:
networksetup -setnetworkserviceenabled Wi-Fi off
and finally I repeated the "on" command. This resulted once again in "Wifi off".
So the command switches between wifi OFF and wifi DISABLED, but not wifi ON.
I would expect the "off" command to work as the "on" command does now (wifi=off) and there must be some command for turning it on. Confusing.
I'll search to see if I can find other options for "networksetup -setnetworkserviceenabled".
UPDATE: aha! I found some information here which I tested working:
Code:
networksetup -setairportpower en0 on
and
Code:
networksetup -setairportpower en0 on
So I'm going to try that in the scripts and see if I get it all working.
..... testing.....
The "on" script almost works with the new wifi command, but while it does enable wifi it doesn't share via wifi but looks for a network instead. Here's the updated script, and I'm wondering what the line in bold does and if it has something to do with it not quite working:
Rich (BB code):
try
do shell script "killall 'System Preferences'"
end try
do shell script "sudo launchctl unload /System/Library/LaunchDaemons/com.apple.NetworkSharing.plist" with administrator privileges
do shell script "sudo /usr/libexec/PlistBuddy -c 'Set NAT:Enabled 1' /Library/Preferences/SystemConfiguration/com.apple.nat.plist" with administrator privileges
do shell script "sudo launchctl load /System/Library/LaunchDaemons/com.apple.NetworkSharing.plist" with administrator privileges
do shell script "networksetup -setairportpower en0 on"
do shell script "open -a /Applications/System\\ Preferences.app"
do shell script "open /System/Library/PreferencePanes/SharingPref.prefPane"
The "off" script appears to work (it switches off wifi and network sharing) -I tried it after "manually" enabling wifi sharing. But as it also has the same "NAT: Enabled" command I can't say for sure if it too needs some tweaking.
Last edited: