How to forget Wi-Fi network in system preferences with Applescript I've been trying to create a script so when I run it, it removes the Wifi network from my remembered list. It's almost finished but I'm stuck on one little bit. Can anybody help me out? Here is my code so far:

tell application "System Preferences"
    activate
    reveal pane "Network"
    delay 1
    tell application "System Events"
        tell process "System Preferences"
            click button "Advanced…" of window "Network"
            delay 1
            click radio button "Wi-Fi" of tab group 1 of sheet 1 of window "Network"
            delay 0.5
            tell application "System Events" to keystroke "Cole"
            delay 0.2
        end tell
    end tell
end tell
I'm not a big fan of UI scripting, but this works for me on the latest version of Sierra.  You may need to adjust the delay values to suit your systems needs.

tell application "System Preferences"
    activate
    reveal anchor "Wi-Fi" of pane id "com.apple.preference.network"
    delay 1
    tell application "System Events"
        tell process "System Preferences"
            click button "Advanced…" of window "Network"
            delay 1
            -- sets focus to the table containing the available Wi-Fi networks
            set focused of table 1 of scroll area 1 of tab group 1 of sheet 1 of window "Network" to true
            delay 1
            keystroke "Cole"
            delay 0.2
            -- this clicks the button "-" to remove that Wi-Fi network from the list
            perform action "AXPress" of button 2 of group 1 of tab group 1 of sheet 1 of window "Network"
            delay 0.2
            perform action "AXPress" of button "Remove" of sheet 1 of sheet 1 of window "Network"
            delay 0.2
            perform action "AXPress" of button "OK" of sheet 1 of window "Network"
            delay 0.2
            perform action "AXPress" of button "Apply" of window "Network"
        end tell
    end tell
    quit
end tell