Automatically disable the wifi

Discussion in 'macOS' started by Muggsy, Apr 10, 2013.

  1. Muggsy macrumors newbie

    Joined:
    Feb 8, 2013
    #1
    Hi everyone

    Do you know how to disable the wifi automatically when shutting down the computer (10.8.2)?
    I have been searching the internet but all I could find was people having problems with this.

    Thanks a lot
    :):):):):)
     
  2. simsaladimbamba

    Joined:
    Nov 28, 2010
    Location:
    located
    #2
    Why is that necessary? If you shut down your computer, the WiFi on your Mac is disabled like everything else.

    Or do you mean something different, like disabling your router's WiFi? If so, how should the router know, that you are available again once you start the Mac anew?
     
  3. Muggsy thread starter macrumors newbie

    Joined:
    Feb 8, 2013
    #3
    Hi

    Sorry it made sense to me, I should have been clearer.
    Basically what I want is to have the wifi OFF when I switch on the computer, whatever status it had when I previously switched the computer off.

    Do you think it is possible?
    :):):):):)
     
  4. Weaselboy Moderator

    Weaselboy

    Staff Member

    Joined:
    Jan 23, 2005
    Location:
    California
    #4
    This should work. Open Applescript Editor and paste in the text below. Then hit command-s and save the script as an application named whatever you want.

    You can drag the application into the Dock if you like. When you launch the application it will turn off wifi and shutdown the machine.

    Code:
    do shell script "networksetup -setairportpower en0  Off"
    delay 1
    tell application "Finder"
    	shut down
    end tell
     
  5. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #5
    A. I'm pretty sure it needs to be en1 rather than en0, though it may depend on the Mac model. I.e. en1 is wifi on Macs with both ethernet and wifi. I don't know what a MacBook Air has for its wifi interface name, since it doesn't ship with ethernet by default.

    B. If just the do shell script line is placed in an AppleScript application, then that app can be added to a user's Login Items, and will run at login. I mention this because it's easier to add things to run at login than it is to add things to run at shutdown or logout.
     
  6. Muggsy thread starter macrumors newbie

    Joined:
    Feb 8, 2013
    #6
    Hi guys

    I was thinking about that option as well if no built in option already existed, as I always use the shortcut to shut the computer down.
    I guess I could also replace that shortcut and make it open the dedicated application with Quicksilver instead, but it would get complicated as a confirmation option would be ideal. If anybody wants to go for a code for that please don't hesitate to put it :)

    Anyway going back to the Start option, what you basically recommend is to simply open Applescript Editor and insert:
    Code:
    [I]do shell script "networksetup -setairportpower en0  Off"[/I]
    Then save the script as an application and paste it in the Login Items.

    Is that right?
    Thanks!
    :):):):):)
     
  7. Bear macrumors G3

    Joined:
    Jul 23, 2002
    Location:
    Sol III - Terra
    #7
    Adding that to login items would power off the wifi at login and not shutdown.
     
  8. Weaselboy Moderator

    Weaselboy

    Staff Member

    Joined:
    Jan 23, 2005
    Location:
    California
    #8
    A. Nope. Before posting this I tested it on my 2012 MBA and it works with en0.

    B. That would leave wifi on at shutdown and it would turn it off shortly after login... yes. I'm not sure if that is what OP is trying to accomplish though.
     
  9. Muggsy thread starter macrumors newbie

    Joined:
    Feb 8, 2013
    #9
    Thanks that has solved my problem.
    It wasn't what I was thinking of originally but it did the trick.
    I just needed indeed to change the en0 into an en1 (I'm on a MacBookPro).

    If anybody wants to add a code for a confirmation of shutdown question to be added to the shutdown+wifiOFF app, it may help someone in the future.

    Thanks again!
    :):):):)
     
  10. Weaselboy Moderator

    Weaselboy

    Staff Member

    Joined:
    Jan 23, 2005
    Location:
    California
    #10
    This will give you a popup with okay/cancel.

    Code:
    display dialog "Are you sure you want to shut down?"
    do shell script "networksetup -setairportpower en1  Off"
    delay 1
    tell application "Finder"
    	shut down
    end tell
     

Share This Page