Connect to a Network with AppleScript

Hi,


I'm trying to build a script to connect to a network (School VPN) already configured in System Preferences.


However I can't make the script to select the proper network configuration in the table on the left (Image).


I want the script to

  1. Open System Preferences -> Network
  2. Click on the 5th network configuration.
  3. Click on connect.


I've written this script but when I compile it, it returns "missing value".


tell application "Finder"
	open file "Macintosh HD:System:Library:PreferencePanes:Network.prefPane"
end tell

--Here says "missing value"
tell application "System Events" to tell process "System Preferences"
	click static text 1 of row 5 of table 1 of scroll area 1 of window 0
end tell

--Now the script needs to click button "connect"

quit application "System Preferences"

Any idea on how could I make this work?


MacBook Pro 16″, macOS 12.0

Posted on Nov 27, 2021 2:10 PM

Reply

Similar questions

2 replies

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Connect to a Network with AppleScript

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.