Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2013
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. set vpnname to {"London", "New York", "Menlo Park"}
  2. set vpnserver to {"vpnserver.london", "vpnserver.newyork", "vpnserver.menlopark"}
  3. set vpnusername to display dialog "Please enter your username (firstname.lastname):" default answer "bob.smith" with icon note
  4. set tmpth to button returned of (display dialog "Please select your group." buttons {"Operations", "Development", "More…"})
  5. if tmpth is "More…" then set tmpth to button returned of (display dialog "Please select your group." buttons {"Finance", "Marketing", "Everyone else"})
  6. if tmpth is "Operations" then
  7.     set grpname to "shazam-ops"
  8.     set shdscr to "password"
  9. end if
  10. if tmpth is "Development" then
  11.     set grpname to "shazam-dev"
  12.     set shdscr to "password"
  13. end if
  14. if tmpth is "Finance" then
  15.     set grpname to "shazam-fin"
  16.     set shdscr to "password"
  17. end if
  18. if tmpth is "Marketing" then
  19.     set grpname to "shazam-mkt"
  20.     set shdscr to "password"
  21. end if
  22. if tmpth is "Everyone else" then
  23.     set grpname to "shazam-ee"
  24.     set shdscr to "password"
  25. end if
  26.  
  27.  
  28. tell application "System Events"
  29.     if not (UI elements enabled) then
  30.         tell application "System Preferences"
  31.             activate
  32.             set current pane to pane id "com.apple.preference.universalaccess"
  33.             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
  34.         end tell
  35.         set UI elements enabled to true
  36.         if UI elements enabled is false then return "User Cancelled"
  37.         delay 1
  38.     end if
  39.     repeat with i from 1 to 3
  40.         tell application "System Preferences"
  41.             --quit saving yes
  42.             delay 3
  43.             activate
  44.             delay 3
  45.             set current pane to pane id "com.apple.preference.network"
  46.             delay 1
  47.             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
  48.            
  49.         end tell
  50.         tell application "System Events"
  51.             activate
  52.            
  53.            
  54.            
  55.            
  56.             tell window 1 of application process "System Preferences"
  57.                 click button "Add service"
  58.                 delay 1
  59.             end tell
  60.             tell sheet 1 of window 1 of application process "System Preferences"
  61.                 click pop up button 1
  62.                 click menu item "VPN" of menu 1 of pop up button 1
  63.                 delay 1
  64.                 click pop up button 2
  65.                 --click menu item "L2TP over IPSEC" of menu 1 of pop up button 2
  66.                 --click menu item "PPTP" of menu 1 of pop up button 2
  67.                 click menu item "Cisco IPSec" of menu 1 of pop up button 2
  68.                 set focused of text field 1 to true
  69.                 keystroke "a" using command down
  70.                 keystroke (item i of vpnname as text)
  71.                 click button 1
  72.                 delay 5
  73.             end tell
  74.             tell group 1 of window 1 of application process "System Preferences"
  75.                 click checkbox 1
  76.                 set focused of text field 3 to true
  77.                 keystroke (item i of vpnserver)
  78.                 keystroke tab
  79.                 keystroke text returned of vpnusername
  80.                 click button 2
  81.                 delay 1
  82.             end tell
  83.             tell sheet 1 of window 1 of application process "System Preferences"
  84.                 set focused of text field 1 to true
  85.                 keystroke grpname
  86.                 keystroke tab
  87.                 keystroke shdscr
  88.                 click button 2
  89.                 delay 1
  90.             end tell
  91.            
  92.             click button 1 of window "Network" of application process "System Preferences"
  93.             click button "Apply" of sheet 1 of window "Network" of application process "System Preferences"
  94.            
  95.            
  96.            
  97.             delay 1
  98.            
  99.         end tell
  100.     end repeat
  101.    
  102.     activate me
  103.     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
  104.    
  105. end tell
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement