windowstcpnetbios

NetBios stack gets cleared when removing LAN cable on Windows 10


I have an ancient component written in C++ that uses netbios to iterate through network adapters to return their MAC address.

All operates fine under windows 7, but since we moved to windows 10 the code fails to retrieve MAC addresses when the LAN cable is removed, all works fine with the LAN cable attached.

On Windows 7, when I use nbtstat -n, I get the netbios list as expected with the LAN cable attached or disconected. On Windows 10, I get the expected list with the LAN cable attached, but an empty list when the LAN cable is removed.

I've looked at power settings and checked netbios is turned on for TCP/IP and all looks good.

Unfortunately the component cannot be recompiled as it is so old and our build machine no longer exists.

I need a way to keep NetBios operating on Windows 10 when there is no LAN cable attached. What currently seems to happen is that the table is cleared when the LAN cable is removed and then the entries are re-registered when it is plugged back in. The table briefly shows 'registering' in the status field before showing 'registered'.

Any ideas would be most appreciated.


Solution

  • The answer is:

    https://support.microsoft.com/en-ie/help/239924/how-to-disable-the-media-sensing-feature-for-tcp-ip-in-windows

    1. Start Registry Editor.
    2. Locate the following registry subkey: HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters
    3. Add the following registry entry to the Parameters subkey: Name: DisableDHCPMediaSense Data type: REG_DWORD (Boolean) Value: 1 Note This entry controls the behavior of Media Sensing. By default, Media Sensing events trigger a DHCP client to take an action. For example, when a connect event occurs, the client tries to obtain a lease. When a disconnect event occurs, the client may invalidate the interface and routes. If you set this value data to 1, DHCP clients and non-DHCP clients ignore Media Sensing events.
    4. Restart the computer.