Netzwerkauswahl + VPN Start

T

thinkart23

Neues Mitglied
Thread Starter
Dabei seit
08.06.2012
Beiträge
13
Reaktionspunkte
0
Hallo Zusammen,
ich bin grade an einem Script was auf Netzwerkumgebung zugreift,dort ist einmal Netzwerk "Privat" und "Öffentlich" hinterlegt.
Bei der Auswahl wird bei Öffentlich ein VPN gestartet und bei "Privat" soll kein VPN Starten.
Wie muß ich "Privat" im Script hinterlegen am besten?


tell application "System Events"
if UI elements enabled then
set UListe to title of every menu item of menu "Umgebung" of menu item "Umgebung" of menu "Apple" of menu bar 1 of process "Finder"
else
tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.universalaccess"
display dialog "UI element scripting is not enabled. Check \"Enable access for assistive devices\""
end tell
end if
end tell

set UListe to items 1 thru -3 of UListe
set Auswahl to choose choose from list {"Automatisch", "Privat"} with prompt "Netzwerumgebung"
if Auswahl is not false then
set Befehl to "scselect " & Auswahl
do shell script Befehl
end if
if Auswahl is "scselect" & Auswahl then "Automatisch"
tell application "System Events"
tell current location of network preferences
set myConnection to the service "VPN"
if myConnection is not null then
if current configuration of myConnection is not connected then
connect myConnection
end if
end if
end tell
end if
if Auswahl is "scselect" & Auswahl then "Privat"
 
Habe noch selber etwas dran verbessert.
Zwei Probleme bestehen noch:
1) Zeitverzögerung bis VPN Verbindung aufbaut
2) Auswahl "Automatisch" auf normal Verbindung einstellen (ohne VPN)
Weis jemand ne Lösung ?
tell application "System Events"
if UI elements enabled then
set UListe to title of every menu item of menu "Umgebung" of menu item "Umgebung" of menu "Apple" of menu bar 1 of process "Finder"
else
tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.universalaccess"
display dialog "UI element scripting is not enabled. Check \"Enable access for assistive devices\""
end tell
end if
end tell

set UListe to items 1 thru -3 of UListe
set Auswahl to choose from list UListe
if Auswahl is not false then
set Befehl to "scselect " & Auswahl
do shell script Befehl
end if
if Auswahl is "scselect" & Auswahl then "Privat"
tell application "System Events"
tell current location of network preferences
set myConnection to the service "VPNXX"
if myConnection is not null then
if current configuration of myConnection is not connected then
connect myConnection
end if
end if
end tell
end tell
if Auswahl is "scselect" & Auswahl then "Open"
tell application "System Events"
tell current location of network preferences
set myConnection to the service "VPNXY"
if myConnection is not null then
if current configuration of myConnection is not connected then
connect myConnection
end if
end if
end tell
end tell
if Auswahl is "scselect" & Auswahl then "Automatisch"
 
So weit bin ich nun,bekomme nur den letzten Fehler nicht weg,bei der Netzwerkauswahl"Automatic",wer kann helfen?

tell application "System Events"
if UI elements enabled then
set UListe to title of every menu item of menu "Umgebung" of menu item "Umgebung" of menu "Apple" of menu bar 1 of process "Finder"
else
tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.universalaccess"
display dialog "UI element scripting is not enabled. Check \"Enable access for assistive devices\""
end tell
end if
end tell

set UListe to items 1 thru -3 of UListe
set Auswahl to choose from list UListe
if Auswahl is not false then
set Befehl to "scselect " & Auswahl
do shell script Befehl
end if
if Auswahl is "scselect" & Auswahl then "Privat"
tell application "System Events"
delay 10
tell current location of network preferences
set myConnection to the service "VPNServer23"
if myConnection is not null then
if current configuration of myConnection is not connected then
connect myConnection
end if
end if
end tell
return 1
end tell
end run
if Auswahl is "scselect" & Auswahl then "Open"
delay 10
tell application "System Events"
tell current location of network preferences
set myConnection to the service "VPNServer23"
if myConnection is not null then
if current configuration of myConnection is not connected then
connect myConnection
end if
end if
end tell
return 1
end tell
end run
if Auswahl is "scselect" & Auswahl then "Automatic"
tell application "System Events"
tell current location of network preferences
set myConnection to do shell script "scselect Automatic"
end tell
end tell
end
return 1
end
end run
 
Zurück
Oben Unten