Script to turn wifi on/off
Hello,
Can someone provide a script that will simply turn on or off wifi as if using doing this manually from the menu bar?
THx!
You can make a difference in the Apple Support Community!
When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.
When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.
Hello,
Can someone provide a script that will simply turn on or off wifi as if using doing this manually from the menu bar?
THx!
Thanks for this. I did google and find a few others before I posted but none of them worked.
This one did work http://www.makiaea.org/post/5993587804 after I changed "en0" to "en1"
THis is working in my MBP:
-- 20110529 www.makiaea.org ref: 20110529wlx-wirelessonoff.applescript
-- wlx toggles wifi (airport wireless) power on and off
-- Tested using macbook air 3,1 , mac os 10.7 (Build 11A459e), quicksilver ß59 (3842)
-- if you are not using quicksilver to run the script, you may need to compile the script first (using applescript editor) and save as an .scpt script or as an app if you want to double–click with the mouse on an icon to run it.
-- note this assumes your wireless ethernet interface is en1
-- get the correct interface from the menu Apple|About This Mac|Network|Wi-Fi or from terminal using ifconfig -a
try
set makiaeawirelessstatus to do shell script "networksetup -getairportpower en1"
on error
display dialog "The script did not work as intended, please check the networksetup command (in terminal) works on your system. It has been tested on mac os 10.7 (Build 11A459e). Other versions of mac os may not have this command available. Please open the applescript in applescript editor for more details." buttons {"kthxbai"}
end try
if makiaeawirelessstatus is "Wi-Fi Power (en1): On" then
do shell script "networksetup -setairportpower en1 off"
else if makiaeawirelessstatus is "Wi-Fi Power (en1): Off" then
do shell script "networksetup -setairportpower en1 on"
else
display dialog "The script did not work as intended, please check your wireless connection is specified correctly. The default in this script is en1 (please open the applescript in applescript editor for more details)" buttons {"kthxbai"}
end if
THx
Thank you this solved my problem, I had to swap Wi-Fi Power (en1): On ----> AirPort Power (en1): On
Script to turn wifi on/off