Script no longer works in 10.9

Hi Guys,

The below script was used in 10.8 to add a VPN profile in system preferences - network.

However now, universal access is no longer an option in 10.9 in system preferences and to allow the system to use automator/the below script we need too get it to look at system preferences/security&privacy/Privacy/Accessibility

I’ve tried playing with the below script (as you can see by the bolded line, I changed to open security & privacy) but I’m getting nowhere - it seems to actually DELETE network profiles rather than add the one described.

Any ideas?

run {input, parameters}
	

	set vpnname to "UK"
	set vpnserver to "62.189.118.238"
	set vpnsecret to "4fe1d057"
	set groupname to "SecaucusVPN"
	

	tell application "System Events"
		if not (UI elements enabled) then
			tell application "System Preferences"
				activate
				[b]set current pane to pane id "com.apple.preference.Security&Privacy"[/b]
				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
		tell application "System Preferences"
			activate
			set current pane to pane id "com.apple.preference.network"
			set vpnusername to display dialog "Please enter your username:" default answer "" with icon note
		end tell
		tell application "System Events"
			tell process "System Preferences"
				tell window 1
					click button 10
					delay 1
				end tell
				tell sheet 1 of window 1
					click pop up button 1
					click menu item "VPN" of menu 1 of pop up button 1
					repeat until exists pop up button 2
						delay 0.2
					end repeat
					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 vpnname
					click button 1
					delay 5
				end tell
				tell group 1 of window 1
					set focused of text field 3 to true
					keystroke vpnserver
					keystroke tab
					keystroke text returned of vpnusername
					click button 2
					delay 1
					click checkbox 1
				end tell
				tell sheet 1 of window 1
					set focused of text field 1 to true
					keystroke groupname
					keystroke tab
					keystroke vpnsecret
					click button 2
					delay 1
				end tell
			end tell
		end tell
	end tell
	

	return input
end run

Are you forced to encapsulate your script in Automator ?
If you aren’t, build a script doing the entire job and save it as an application.
Then the 1st time you will run it you will be asked if you allow the app to use accessibility tools and you will no longer be asked later.

Yvan KOENIG (VALLAURIS, France) mardi 5 novembre 2013 15:52:04