I have a Windows 10 machine which, for reasons, must be connected to a LAN and a WiFi simultaneously, most of the time, and only to one of them on occasion. Now, I would like the WiFi to be the default route, and the LAN to only be used for addresses in some subnet.
The subnet part is easy:
route -p ADD 192.168.0.0 MASK 255.255.0.0 192.168.0.1 METRIC 10
or a similar command will persist the routing rule of preferring the LAN for traffic to 192.168.0.0/24. You run this once and forget about it.
My problem is with the default route. I can't persist a default route to the WiFi, since sometimes it's simply invalid; while the LAN rule, while sometime invalid, never clashes with anything, since when it's invalid I can't access that LAN anyway.
I would like to either tell the OS, once and for all "Prefer this WiFi network / this WiFi adapter for defining the default route", or alternatively, find some hook for a command to run after the WiFi is connected, which I will use to write something like:
route DELETE 0.0.0.0 MASK 0.0.0.0 192.168.0.1 METRIC 35
(or whatever the default route via the LAN looks like.)
How can I achieve that?