|This command ("netsh") is new to me, but after testing, it seems to me there might be more than one network service connected. My tests showed two live connections for my system. First you need to examine your system to see what's "out there" and what's enabled. The batchfile you posted is not adequate for what you want to do. It will branch to "enable" the realtek only if NO other service is "Connected". If ANY service is "Connected", the realtek will be disabled. Your first mission, (should you decide to accept it) is to run: "netsh interface show interface" from the command-prompt. If there's more than one line of detail, your batch needs to account for those other lines, or specifically ignore them by specifying only the realtek interface. Here's a simple example that will do that, on a "non-toggle" basis, for this (realtek) item only:|
netsh interface set interface "Realtek PCle FE Family Controller" disabled
netsh interface set interface "Realtek PCle FE Family Controller" enabled
This switches it on or off, regardless of its current status. If it's already in the specified state, nothing happens anyway.
I'm guessing you don't care what state it is currently in, you simply want it ON or OFF. If you want to "toggle" it ON/OFF, THEN you need to test for "Connected" and establish the identity of the connection (ie: Ethernet, wifi, etc) before you toggle it to the opposite state. I'll wait (probably forever) to see which scenario you wish to pursue.