2011年12月31日星期六

根据需要切换MBA的网络

最近开始带着MBA上班,办公室的网络需要指定IP,而家里的网络是DHCP自动获得IP。所以每次都需要切换网络设置的位置。我建立了两个配置,一个叫Office,一个叫Home。于是决定写个applescript来方便的切换配置。

这里备份一下,以备将来查询。


set location to the button returned of (display dialog "Please choose the network location" buttons {"Office", "Home"} default button 1)
set cmd to "scselect " & location
tell application "System Events"
tell network preferences
do shell script cmd
end tell
end tell

--wait for 2 seconds to connect openvpn
delay 2

--connect openvpn
tell application "Tunnelblick"
activate
disconnect all
connect "puff"
end tell

--wait for 5 seconds to open adium
delay 5

--start adium
tell application "Adium"
activate
go online
end tell



没有评论:

发表评论