How to start/stop Internet Sharing using AppleScript
applescript
Solution
You can use launchctl to programmatically start or stop the Internet Sharing service.
The following AppleScript will start Internet Sharing:
do shell script "/bin/launchctl load -w /System/Library/LaunchDaemons/com.apple.InternetSharing.plist" with administrator privileges
The following AppleScript will stop Internet Sharing:
do shell script "/bin/launchctl unload -w /System/Library/LaunchDaemons/com.apple.InternetSharing.plist" with administrator privileges
Problem
I don't have a Wi-Fi router, so when at home I need to turn my laptop into a Wi-Fi source so that both myself and my partner can access the internet. However during the days I work at a coffee shop and require the use of their Wi-Fi. I'm running Snow Leopard and I find it stupidly cumbersome to constantly be turning off and on, first Internet Sharing and then my Wi-Fi. Any ideas for a quick 'n' dirty AppleScript solution?