There may be such a need. When we are in the company, we need to enable the gateway verification program after connecting to the company's network, and enable the VPN after connecting to the network at home. That is, you want to execute certain programs when connecting to a specific network.
Step 0.Preparation
Clear thinking: When the network changes, some events will be recorded, so the specific program we execute will be recorded after some specific events.
Related procedures: Control Panel-management tools-view log events, control panel-management tools-Schedule Tasks
[01]
[02]
Step 1.Connect to the network to obtain a specificEvent ID.
In the left-side tree of the NIC connection log event, expand: Application and service logs-Microsoft-Windows-WLAN-AutoConfig-Operational. First, clear the logs and connect to the company's network. Next we can see a series of events.
[11]
From the event details, confirm the corresponding networkSSID. (The IDs of network events are different)
[12]
Step 2.Attach the operations of the execution program to a specific event
[21]
After setting, you can view the corresponding event in the scheduled task.
[22]
Step 3.When the network is disconnected, close the program in the previous step.
Clear Microsoft-Windows-WLAN-AutoConfig-Operational logs when the network connection is normal, and then disconnect the network. Find the corresponding event ID and repeat Step 2.
PS: linux, ubuntu directly put the script in/etc/network/if-up.d/and/etc/network/if-dn.d/, mac osx has not found the corresponding method, if you know anything, please let us know. Thank you.