Running netsh interface ipv4 show interfaces in cmd shows some network interface information, including the state (connected or disconnected). Is this information stored in the registry and, if so, where can I find it?
I know IP addresses are found in subkeys of HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces (as answered here), but I'm not seeing state information there. I found the StaleAdapter value in subkeys of HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\DNSRegisteredAdapters, which updates on connection/disconnection. However, I doubt that this is really what I'm looking for, as there are less subkeys than there are network interfaces in the netsh output.
1 Answer
I doubt it. There's no reason to store such info onto disk. The OS can just ask the network card. On the other hand, DHCP addresses have a benefit to being written to disk. If a computer loses power, upon being restored, it may be able to request the same address from the DHCP server (but not necessarily expect that request to be honored).
If you want to be able to access things through a method other than the GUI, you might find you can get such info using WMI.
One way to work with WMI is to use the WMIC command. The following may show some details about the status of network cards.
WMIC NIC WHERE (NetEnabled=TRUE) GET Availability,Index,Name,MACAddress,NetEnabled,NetworkAddresses,Speed /FORMAT:LIST
That is just a selection I've chosen. (If you see "Invalid query", try removing some of the items until you find out which query was invalid.) To see even more, you can run:
WMIC NIC WHERE (NetEnabled=TRUE) GET /FORMAT:LIST