You are not logged in.
Hi Everyone,
I have a relatively simple script that automates a VPN connection (using Apple's VPN Connect) to my wife's work server. It simply told the application Internet Connect to activate, and the rest would take care of itself. But Leopard doesn't have Internet Connect as a freestanding application. Rather, VPN connections are now within the Network preference pane. So, how do I tell AS to launch a VPN connection from inside Leopard's Network Prefs? I think it should be simple, but I couldn't find any clues online. Thanks in advance.
Joe
Offline
Hi,
the scriptability of network preferences has been massively improved in Leopard
Try this
Applescript:
tell application "System Events"
tell current location of network preferences
set VPNservice to service "VPN (L2TP) 2" -- name of the VPN service
if exists VPNservice then connect VPNservice
end tell
end tell
regards
Stefan
Offline
Thanks, Stefan! I'll give it at try when I get home. I figured it would be improved in Leopard, but it wasn't obvious to me how to identify the VPN's location. It makes perfect sense, though, given your code.
Joe
Offline
Hi Stefan (and Everyone),
It worked like a charm. May I impose on you, though, for one last bit of help? How do I check if the VPN is active? With Internet Connect it was pretty simple, but not sure how to do it in Leopard. The idea is to make sure the VPN is connected before mounting network drives. Thanks in advance.
Joe
Offline
try this
Applescript:
tell application "System Events"
tell current location of network preferences
set VPNservice to service "VPN (L2TP) 2" -- name of the VPN service
set isConnected to connected of current configuration of VPNservice
if isConnected then
-- do something
end if
end tell
end tell
regards
Stefan
Offline
That's great for a VPN, but I use to use tell "internet connect" to connect, to dail up to the internet. Now all my scripts don't work anymore in Leopard.
Offline
That's great for a VPN, but I use to use tell "internet connect" to connect, to dail up to the internet. Now all my scripts don't work anymore in Leopard.
Internet Connect.app has vanished in Leopard, use network preferences in System Events instead
regards
Stefan
Offline
I missed the
--tell current location of network preferences--
now it works!!
I do it like this now:
Applescript:
tell application "System Events"
tell current location of network preferences
set Modemdailup to service "HUAWEI"
if exists Modemdailup then connect Modemdailup
end tell
end tell
Last edited by Rush (2008-02-12 08:50:23 am)
Offline
sorry to bring this back from dead,
I am trying to get the "time connected" of current modem connection.
its the time that shows on menu bar and tells how long you have been connected to internet via modem.
on "Internet Connect" it was seconds connected.
any ideas?
thanks alot
Last edited by amet (2008-09-19 12:30:13 am)
Offline