Apple Script / launchd way to keep WiFi on?

Discussion in 'Mac Programming' started by jagak, Aug 8, 2013.

  1. jagak macrumors newbie

    Aug 8, 2013
    So we have a group of students that like to turn their wifi off to goof around on their school computers during class w/o the teacher being able to see what they are doing remotely. I'd like to make it so they cannot turn off their wifi. I have a current solution utilizing apple script and a plist that checks airportstatus every 10 seconds and if it finds that it is off it turns it back on... I'd like something a bit smarter than that and less demanding on the computer. I've seen something similar to what I want in the link below for turning WiFi off when ethernet is plugged in but so far I've not been able to hone it down to simply watch for a change in airport power then make the change.

    When I put everything together from the link above on my macbook pro if i turn off wifi it turns back on immediately which is what I want but not how it was designed to work and also it does not work at all on the student macbook airs due to the fact they have no ethernet so en0 is wifi... I did attempt to simply replace en1 with en0 where applicable but that got me nowhere.

    Basically I want something that detects a change in en0 from on to off and when en0 is off run the command to turn it back on and that doesn't rely on an apple script running on interval like what I have now. Any ideas?
  2. chown33 macrumors 604

    Aug 9, 2009
    Sailing beyond the sunset
    System Preferences > Network > Wi-Fi > "Advanced..." button

    In the sheet that's displayed, look at the lower part. There should be text that says "Require administrator authorization to:" followed by 3 checkboxes:
    • Create computer-to-computer networks
    • Change networks
    • Turn Wi-Fi on or off
    Check the 3rd checkbox.

    This assumes the students don't have an admin account, or knowledge of the admin password.
  3. ArtOfWarfare macrumors G3


    Nov 26, 2007
    Two things I would look into:

    1 - Write a small C program that runs in the background. It would simply set up a callback function using SystemConfiguration.framework's SCNetworkReachabilitySetCallback, and then it would make sure the wifi was turned on (and turn it on if it wasn't) each time it was called.

    2 - Write an AppleScript that disables the wifi menu, as well as the system preferences.

    I'm not very familiar with AppleScript so I wouldn't do it, but this looks like it could be helpful:


    Damnit, Chown's answer is better than mine. I'd definitely do what he said.

Share This Page