Macro to switch between 2 different WiFi networks

I am trying to build a macro to connect to 2 different wifi networks at 2 different times. In other words, I want my mac to connect to network A at 9am and to connect to network B at 7pm.
My first approach was to switch on and off the wifi at the predetermined times. However, to be able to connect to the right wifi network, I will have to be able to change the order of my preferred networks using KM. Is this possible?

How else can I go about it?

1 Like

Can you set up two Network Locations and then change network location (which there is a location for).

I use both networks in then same location. The only variable that changes is time.

Hey Mirizzi,

The point is that you can create different Network Locations (Configurations) in the System Network Preference Pane.

Keyboard Maestro is able to access these and switch between them using the 'Set Network Location' Action.


I was not able to set up Network location to work consistently.
So, I used this shell script

networksetup -setairportnetwork en1 "Network Name" password

Can somebody help me with this? I tried this today (5 years after this topic was created) but only get an error message from KeyboardMaestro saying: "Task failed with status 10".

My exact wording is:

networksetup -setairportnetwork en1 “[name of my network]” [password (no quotes here)]

1 Like

When I changed en1 to en0, it worked in Terminal, but not in Keyboard Maestro. When I added /usr/sbin/ before networksetup, it works in KM. So,

/usr/sbin/networksetup -setairportnetwork en0 “[name of my network]” [password (no quotes here)]