calls to INetworkListManager GetConnectivity in fail

Dennis 1 Reputation point

Actual behavior:
calls to INetworkListManager GetConnectivity in fail.
INetworkListManager Network calls are not working in Docker:
INetworkListManager GetConnectivity returns 0x80070422 = The service cannot be started, either because it is disabled or because it has no enabled devices associated with it.

netprofm service is not running by default in this image. Setting its status to Automatic:

Set-Service 'netprofm' -StartupType Automatic 

now fails differently with:
0x8007042c = ERROR_SERVICE_DEPENDENCY_FAIL = The dependency service or group failed to start.

Expected behavior:
INetworkListManager GetConnectivity should return a value > 3 to indicate ipv4 or ipv6 is available.

Windows Version: 10 pro. 20H2, build 19042.804
Docker Desktop Version: 3.2.1 WSL2 or Hyper-V backend? WSL2
Are you running inside a virtualized Windows e.g. on a cloud server or a VM? a locally hosted VM

Steps to reproduce the behavior:
start instance of
run test app (TestNetStatus source below) to call INetworkListManager GetConnectivity

optionally i can call: (in a powershell connection to the VM)

Set-Service 'wmiApSrv' -StartupType Automatic 
Set-Service 'nlasvc' -StartupType Automatic 
Set-Service 'netprofm' -StartupType Automatic 
Start-Service 'netprofm' Start-Service 'wmiApSrv' 
Start-Service 'nlasvc' 

rem re-run TestNetStatus and we now get 3 (NLM_CONNECTIVITY_IPV4_NOTRAFFIC). (Still no connectivity)



REM this will fail since it uses ie ?
rem prevent possible IE popup from blocking us.

$keyPath = 'Registry::HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Internet Explorer\Main' 
if (!(Test-Path $keyPath)) { New-Item $keyPath -Force | Out-Null } 
Set-ItemProperty -Path $keyPath -Name "DisableFirstRunCustomize" -Value 1 

rem OK but does not fix status problem wget
rem wget now works but its possibly unrelated to INetworkListManager failure.

Try Testing a different docker image:

docker run --rm 

rem stops immediately with no messages.

docker pull 

rem fails with: Error response from daemon: manifest for not found: manifest unknown: manifest tagged by "latest" is not found

TestNetStatus Sources:

// TestNetStatus.cpp : This file contains the 'main' function. Program execution begins and ends there.
// This tests the network connectivity the same way that UDC does. 
// This currenntly fails in Docker using image

#include <windows.h>  // HRESULT
#include <iostream>       // std::cout
#include <string>     // std::to_string 
#include <iomanip>
#include <sstream>
#include <atlcomcli.h>    // CComPtr
#include <netlistmgr.h>   // INetworkListManager
#include <objbase.h>

HANDLE g_hLogFile = NULL;

void LogLine(std::string s)

    std::cout << s << "\n";

    if (g_hLogFile != NULL)
        DWORD dwWritten = 0;
        ::WriteFile(g_hLogFile, s.c_str(), (DWORD)s.length(), &dwWritten, nullptr);
        ::WriteFile(g_hLogFile, "\n", 1, &dwWritten, nullptr);

template< typename T >
std::string to_hexstr(T i)
    std::stringstream stream;
    stream << "0x" << std::setfill('0') << std::setw(sizeof(T) * 2) << std::hex << i;
    return stream.str();

int main()
    g_hLogFile =  ::CreateFileA("c:\\temp\\TestNetStatus.log", GENERIC_WRITE,
        FILE_SHARE_READ, nullptr, OPEN_ALWAYS,
    ) ;
    if (g_hLogFile != NULL)
        ::SetFilePointer(g_hLogFile, 0, nullptr, SEEK_END);

    LogLine("TestNetStatus v1.2");

    HRESULT hRes = ::CoInitializeEx(0, COINIT_MULTITHREADED);
    if (FAILED(hRes))
        LogLine( "FAIL CoInitializeEx " + to_hexstr(hRes) );
        return -1;

#if 1
    // The impersonation level must be at least RPC_C_IMP_LEVEL_IMPERSONATE.
    hRes = ::CoInitializeSecurity(NULL, -1, NULL, NULL,
        NULL, EOAC_NONE, 0);
    if (FAILED(hRes))
        LogLine("FAIL CoInitializeSecurity " + to_hexstr(hRes));
        // return -2;   // Try anyhow?


    CComPtr<INetworkListManager> pNLM;
    hRes = ::CoCreateInstance(CLSID_NetworkListManager, NULL,
        CLSCTX_ALL, __uuidof(INetworkListManager), (LPVOID*)&pNLM);
    if (FAILED(hRes))
        LogLine("FAIL CoCreateInstance " + to_hexstr(hRes) );
        return -3;

    hRes = pNLM->GetConnectivity(&con);
    if (FAILED(hRes))
        // fails with 0x8007042c in Docker = ERROR_SERVICE_DEPENDENCY_FAIL
        LogLine("FAIL GetConnectivity " + to_hexstr(hRes));
        return -4;

        LogLine("Network OK = " + to_hexstr(con));
        return 1;
        LogLine("Network Offline = " + to_hexstr(con));
        return 0;
Windows Server
Windows Server
A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.
12,611 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Dennis 1 Reputation point

    When submitting my question it gave me an error because i had not supplied a tag. once i supplied the tag i submitted the question and I discovered it has stripped the question of all line breaks. There is no way for me to edit my question.