News, tips, advice, support for Windows, Office, PCs & more
Home icon Home icon Home icon Email icon RSS icon

We're community supported and proud of it!

  • Change network connection from Public to Private

    Home Forums Developers, developers, developers DevOps Lounge Change network connection from Public to Private

    Viewing 1 reply thread
    • Author
      • #2304100
        Rick Corbett

        Just recently a WSL member had a problem changing a Windows 10 network connection from the default Public to Private when the GUI settings to do this were missing.

        Further research shows that there’s a documented method of enumerating network connections. This can be used via COM to iterate through each network connection, changing the value for ‘Category’ to 1, i.e. Private.

        I’m not at all familiar with PowerShell but, using AutoHotkey, this can be accomplished by the following:

        SetBatchLines, -1
        NetworkListManager := ComObjCreate(“{DCB00C01-570F-4A9B-8D69-199FDBA5723B}”)
        IEnumNetworkConnections := NetworkListManager.GetNetworks(NLM_ENUM_NETWORK_ALL := 3)
        for INetwork in IEnumNetworkConnections
                INetwork.SetCategory(1) ; NLM_NETWORK_CATEGORY_PRIVATE

        This is better than changing the ‘Category’ value via the registry, not least of which is that it can be carried out ‘on-the-fly’ to a currently-connected network.

        I’ve added this because it should be possible to help people in future like the OP who have a similar issue… and ‘cos I’ve just discovered the method. 🙂

        Hope this helps…

      • #2304120
        Paul T
        AskWoody MVP

        This post has a similar Powershell version.

        cheers, Paul

    Viewing 1 reply thread

    Please follow the -Lounge Rules- no personal attacks, no swearing, no politics or religion.

    Reply To: Change network connection from Public to Private

    You can use BBCodes to format your content.
    Your account can't use Advanced BBCodes, they will be stripped before saving.