Skip to content

Instantly share code, notes, and snippets.

@legalcodes
Created August 7, 2018 20:37
Show Gist options
  • Save legalcodes/71fed9d481f7504175e6584fb479369a to your computer and use it in GitHub Desktop.
Save legalcodes/71fed9d481f7504175e6584fb479369a to your computer and use it in GitHub Desktop.

Applescript for disconnecting and re-connecting wired ethernet connection

tell application "System Preferences"
	activate
	set the current pane to pane id "com.apple.preference.network"
	get the name of every anchor of pane id "com.apple.preference.network"
	reveal anchor "Ethernet" of pane id "com.apple.preference.network"
	

end tell
tell application "System Events"
	tell process "System Preferences"
		get window "Network"
		get entire contents of window "Network" --> click ((pop up buttons of window "Network") whose description is "Disconnect")
		click button "Disconnect" of group 1 of window "Network"
		delay 2
		click button "Connect" of group 1 of window "Network"
		
	end tell
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment