Apple introduced a new “feature” with MacOSX Lion (10.7) called the Captive Network Assistant. In my opinion, this is just a useless and annoying feature. It aims to help you log in to networks that require authentication (see Captive Portal ), but the function does not store cookies or saves passwords.
At my university, we also use a network that requires users to log in. Login does not occur through the browser, but through the VPN, which makes Captive Network Assistant completely useless and annoying.
So, I posted a guide here on how to replace this “feature” with something really useful, and I didn't want it to get lost and be useful to other people.
# 1.create a bash script called "Captive Network Assistant", paste the following code inside and replace your file with the same in / System / Library / CoreServices / Captive Network Assistant.app/Contents/MacOS/
#!/bin/bash scriptlocation="/System/Library/CoreServices/Captive Network Assistant.app/Contents/MacOS/vpn.scpt" osascript "$scriptlocation"
# 2.create an applicator named "vpn.scpt", place it under the path specified in the bash - script, and place the following code inside:
set wlanssid to do shell script "networksetup -getairportnetwork en1 | cut -c 24-" connectVPN(wlanssid) on connectVPN(SSID) tell application "System Events" tell current location of network preferences local VPNService if (SSID = "XYZXYZ") then --WLANNAME set VPNService to service "XYZXYZ-VPN" --VPNNAME set isConnected to connected of current configuration of VPNService if not isConnected then connect VPNService end if end if end tell end tell end connectVPN
This script will be executed every time your computer connects to the "Captive Network" and if the WLAN SSID is called "XYZXYZ", it will start a VPN connection called XYZXYZ-VPN
The script can be modified to support several inactive networks.
It is also possible to add Growl-Notifications to Script. My full script is as follows: http://pastebin.com/Rtp9EqQR