Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- set vpnname to {"London", "New York", "Menlo Park"}
- set vpnserver to {"vpnserver.london", "vpnserver.newyork", "vpnserver.menlopark"}
- set vpnusername to display dialog "Please enter your username (firstname.lastname):" default answer "bob.smith" with icon note
- set tmpth to button returned of (display dialog "Please select your group." buttons {"Operations", "Development", "More…"})
- if tmpth is "More…" then set tmpth to button returned of (display dialog "Please select your group." buttons {"Finance", "Marketing", "Everyone else"})
- if tmpth is "Operations" then
- set grpname to "shazam-ops"
- set shdscr to "password"
- end if
- if tmpth is "Development" then
- set grpname to "shazam-dev"
- set shdscr to "password"
- end if
- if tmpth is "Finance" then
- set grpname to "shazam-fin"
- set shdscr to "password"
- end if
- if tmpth is "Marketing" then
- set grpname to "shazam-mkt"
- set shdscr to "password"
- end if
- if tmpth is "Everyone else" then
- set grpname to "shazam-ee"
- set shdscr to "password"
- end if
- tell application "System Events"
- if not (UI elements enabled) then
- tell application "System Preferences"
- activate
- set current pane to pane id "com.apple.preference.universalaccess"
- display dialog "This script requires access for assistive devices be enabled." & return & return & "To continue, click the OK button and enter an administrative password in the security dialog." with icon note
- end tell
- set UI elements enabled to true
- if UI elements enabled is false then return "User Cancelled"
- delay 1
- end if
- repeat with i from 1 to 3
- tell application "System Preferences"
- --quit saving yes
- delay 3
- activate
- delay 3
- set current pane to pane id "com.apple.preference.network"
- delay 1
- if i = 1 then display dialog "This script will now create the Shazam VPN connections." & return & return & "Please wait as the operation is in progress, and do not click anything. This should not take longer than 30 seconds. You will be notified when the process is complete." with icon caution
- end tell
- tell application "System Events"
- activate
- tell window 1 of application process "System Preferences"
- click button "Add service"
- delay 1
- end tell
- tell sheet 1 of window 1 of application process "System Preferences"
- 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
- --click menu item "PPTP" of menu 1 of pop up button 2
- click menu item "Cisco IPSec" of menu 1 of pop up button 2
- set focused of text field 1 to true
- keystroke "a" using command down
- keystroke (item i of vpnname as text)
- click button 1
- delay 5
- end tell
- tell group 1 of window 1 of application process "System Preferences"
- click checkbox 1
- set focused of text field 3 to true
- keystroke (item i of vpnserver)
- keystroke tab
- keystroke text returned of vpnusername
- click button 2
- delay 1
- end tell
- tell sheet 1 of window 1 of application process "System Preferences"
- set focused of text field 1 to true
- keystroke grpname
- keystroke tab
- keystroke shdscr
- click button 2
- delay 1
- end tell
- click button 1 of window "Network" of application process "System Preferences"
- click button "Apply" of sheet 1 of window "Network" of application process "System Preferences"
- delay 1
- end tell
- end repeat
- activate me
- display alert "The VPN has been configured. Click on the \"Connect\" button to access the network." & return & return & "The connection status and various options are available through the menu bar at the top of the screen." as informational
- end tell
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement