签署Applescript应用程序,因此它不会要求输入密码

时间:2016-03-07 01:30:13

标签: macos security passwords applescript vpn

我有一个我编写的AppleScript应用程序修改了我的网络设置,以便将我连接到我的vpn提供程序。问题:每次我想运行它时都会询问我的密码。 希望解决方案:无需密码即可运行。

(************************   Run   *************************)
on run #{VPNconfiguration}
    set rand_vpn to random_vpn()
    set VPNconfiguration to pick_vpn(rand_vpn) # Returns a list with one item
    set VPNconfiguration to item 1 of VPNconfiguration # Selects that item from the list
    connect_vpn(VPNconfiguration)
end run

(********************   Random Vpn   **********************)
on random_vpn()
    set rand_vpn to some item of {"US-Cali", "US-West", "US-East", "US-Midwest", ¬
        "US-Texas", "US-Flordia", "US-Seattle", "US-Siliconvallay", "US-NewYorkCity"}
    return rand_vpn
end random_vpn

(*********************   Pick Vpn   ***********************)
on pick_vpn(rand_vpn)
    set VPNconfiguration to choose from list {¬
        "US-Cali", "US-West", "US-East", "US-Midwest", "US-Texas", "US-Flordia", ¬
        "US-Seattle", "US-Siliconvallay", "US-NewYorkCity", "Mexico", "Brazil", ¬
        "Canada", "Canada-Toronto", "UK-London", "UK-Southampton", "German", ¬
        "France", "Switzerland", "Netherlands", "Sweden", "Romania", "Hong-Cong", ¬
        "Isreal", "Russia", "Turkey", "Singapore", "Australia", "Australia-Melbourne", "Japan"} ¬
        with title ¬
        "VPN Connection Client" with prompt ¬
        "Choose One Location" OK button name ¬
        "This VPN" cancel button name ¬
        "Quit" default items {rand_vpn}
    if result = false then quit
    return VPNconfiguration
end pick_vpn

(********************   Connect Vpn   *********************)
on connect_vpn(VPNconfiguration)
    tell application "System Events"
        tell network preferences
            tell current location
                set aPPPoEService to a reference to configuration VPNconfiguration of service "AllVPNs"
                connect aPPPoEService
            end tell
        end tell
    end tell
end connect_vpn

(***********************   Quit   *************************)
on quit
    continue quit
end quit

0 个答案:

没有答案