Hello MacScripter Forums! I am a new member to these boards and this is my first post. First of all I am not a seasoned AppleScript user by any means. But I am trying to learn and this seems like the best place to do that. I have a script that turns VPN on and off depending on its current status; If on it turns off, If off it turns on. I didn’t write this script, I found it (probably on this site though I can’t be sure anymore.) It used to word flawlessly before upgrading to El Capitan. Now it only works if I setup and use L2TP when before I was using Cisco IPSec. When I try to use Cisco IPSec it returns this error:
error “System Events got an error: Can’t get current configuration of service id "6508D6E2-6BE4-4698-913B-EDFECE4BE6B9" of network preferences.” number -1728 from current configuration of service id “6508D6E2-6BE4-4698-913B-EDFECE4BE6B9” of network preferences
Any and all help would be very much appreciated. Thank you.
Here is the AppleScript:
tell application "System Events"
tell current location of network preferences
set VPNservice to service "VPN (Cisco IPSec)"
if exists VPNservice then
set isConnected to connected of current configuration of VPNservice
if isConnected then
disconnect VPNservice
set msg to "Disconnected"
else
connect VPNservice
set isConnectedCheck to false
set x to 0
repeat 10 times
set x to (x + 1)
set isConnectedCheck to connected of current configuration of VPNservice
if isConnectedCheck then
set msg to "Connected success in " & (x * 2) & "s "
exit repeat
else
delay 2
end if
end repeat
if not isConnectedCheck then
set msg to "Connect fail in 20s"
end if
end if
end if
end tell
end tell
Model: iMac
AppleScript: 2.8.1
Browser: Safari 9.0.3
Operating System: Mac OS X (10.10)