Thursday, July 9, 2020

#1 2020-06-30 07:02:23 am

snips
Member
Registered: 2020-06-29
Posts: 1

Automation of VPN connection creation

I'm looking for some help on creating an applescript/debugging for creating an L2TP VPN connection with a preshared key.  I have the script creating the connection and filling in the username, and server address.  However, I can't get it to go into Authentication Settings and add in the pre-shared key then apply.  Here is the code that I have so far.  This is the link that i've been working off of (https://macscripter.net/viewtopic.php?id=37392)

set VPN to "test VPN"
set VPNServer to "testvpn.com"
set VPNUser to "test"
tell application "System Preferences"
    reveal pane "Network"
    activate
    tell application "System Events"
        tell process "System Preferences"
            tell window 1
                click button "Add Service"
                tell sheet 1
                    click pop up button 1
                    click menu item "VPN" of menu 1 of pop up button 1
                    delay 1
                    click pop up button 2
                    click menu item "L2TP over IPSec" of menu 1 of pop up button 2
                    keystroke tab
                    keystroke VPN
                    click button "Create"
                    delay 1
                    keystroke tab
                    keystroke tab
                    keystroke VPNServer
                    keystroke tab
                    keystroke VPNServer
                    keystroke tab
                    keystroke VPNUser
                end tell
            end tell
        end tell
        delay 1
        keystroke "w" using {command down}
    end tell
end tell

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)