Script to turn on/off Internet Sharing


property bOff : true

tell application "System Preferences"
	activate
end tell

tell application "System Events"
	tell process "System Preferences"
		click menu item "Sharing" of menu "View" of menu bar 1
		delay 2
		tell window "Sharing"
			click checkbox 1 of row 11 of table 1 of scroll area 1 of group 1
			delay 1
			set bOff to true
			if (exists sheet 1) then
				set bOff to false
				if (exists button "Turn Wi-Fi On" of sheet 1) then
					click button "Turn Wi-Fi On" of sheet 1
					delay 1
				end if
				click button "Start" of sheet 1
			end if
			if bOff then
				do shell script "echo <password> | sudo -S /usr/sbin/networksetup -setairportpower en1 off"
			end if
		end tell
	end tell
end tell

ignoring application responses
	tell application "System Preferences" to quit
end ignoring

If Internet Sharing is off, tun it on (and also turn on Wi-Fi network adapter, if off).
If Internet Sharing is on, turn it off (and also turn off Wi-Fi network adapter).

PS insert your admin password on in order to disable Wi-Fi adapter.

Model: iMac
AppleScript: 2.2.1
Browser: Safari 535.7
Operating System: Mac OS X (10.7)