Windows 10 Preview does not allow you to change a network from public to private


 

*** UPDATE:

This morning my Microsoft colleague Regan Murphy who is Technical Evangelist pointed me out that Windows 10 indeed can change from public to private via U (thank you Regan)I. I am posting his response below. I am keeping the original post as it may be useful for bulk changes and for System Administrators. My particular problem was not with Wi Fi but with USB Ethernet that even though works when I am at corpnet it fails when I am using my VerizonFIOS wired connection at home. So, try the method below first. Try my solution in the worst case scenario or if you are System Admin. I somehow have the worst case scenario every time I update to a new build. 

UPDATE 2: My source informed that the steps below were introduced on build 1074 so you indeed had a problem before this just released build (I knew I was not crazy after all).

Start of Regan Murphy’s approach

It’s actually pretty easy to switch Public/Private without all the unnecessary effort you described if you know which knob to hit…..

· Go to Network Settingsclip_image001

· Select network and hit “Advanced Options” link

clip_image002

· Toggle the “Find devices and content” (or whatever it happens to be called in the build you’re using J)

clip_image003

·  The network will toggle Public/Private accordingly:

clip_image005

clip_image007

End of Regan Murphy’s approach

 

Original Post (or if everything else fails)

If you are one of the Windows 10 Technical Preview users you may have experienced a very annoying behavior: every time you update your bits or install security patches your network changes from private to public. Private networks cannot share resources nor access some domain resources via VPN or direct access.

You can see the network category in Control Panel | Network and Internet | Network and Sharing Center. Below you see an example of a “Public Network”:

image

In Windows 8 and Windows 8.1 you can change this pretty quickly, see more details here: http://answers.microsoft.com/en-us/insider/forum/insider_wintp-insider_web/any-way-to-change-network-from-public-to-private/6ca4a5ff-e692-465f-b6e2-b5abfaeecf43

Windows 10 does not offer a straightforward way and though the solution I will present works for Window 7 to Windows 10 it was meant to be used in Windows 10 as you can do via UI in previous version.

The solution is simple and it is rather a way to offer an alternative to change the registry directly. The key we need to change (again from Windows 7 to Windows 10) is HKLM\SOFTWARE\Microsoft\WindowsNT\CurrentVersion\NetworkList\Profiles. The application will list all available network, even those Starbucks wireless networks you joined a long time ago. You just need to choose the network name/description and change from Public to Private (or from Private to Public if it is the case). Below is the screenshot. Please be aware that you have to move away from the field (click another field or line) for the changes to be applied. You will be asked to confirm if you meant to do the change, don’t worry. If you confirm, then your network will change the category. Please notice that you HAVE to accept the license to use the application (GNU 2). Don’t forget to click anywhere else after changing the type so that the changes can take effect.

image

After that, the network is set to private:

image

 

Source Code

Both Source Code and executable can be downloaded here: Fix Network Public to Private Windows 10 Preview

This is the code doing most of the work:

   1: // This sample code is provided “AS IS” with no guarantees and its meant for proof-of-concept ONLY. 
   2: // You need to accept this license to use it: http://rodneyviana.codeplex.com/license
   3:  
   4: //The code samples are provided AS IS without warranty of any kind.
   5: // The author disclaims all implied warranties including, without limitation,
   6: // any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages. 
   7:  
   8: using System;
   9: using System.Collections.Generic;
  10: using System.Linq;
  11: using System.Text;
  12: using Microsoft.Win32;
  13: using System.Windows.Forms;
  14:  
  15: namespace FixNetworkVisibility
  16: {
  17:  
  18:     public class RegUtil
  19:     {
  20:         public static string RegistryLastError = null;
  21:  
  22:         public const string NetworkRegPath = @"SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Profiles";
  23:  
  24:         public static RegistryKey OpenKey(string Path = NetworkRegPath, bool ReadOnly = true)
  25:         {
  26:             RegistryKey key = null;
  27:  
  28:             try
  29:             {
  30:                 key = Registry.LocalMachine.OpenSubKey(Path, !ReadOnly);
  31:             }
  32:             catch (Exception ex)
  33:             {
  34:                 RegistryLastError = String.Format("{0}: {1}", ex.GetType().ToString(), ex.Message);
  35:             }
  36:  
  37:             return key;
  38:  
  39:         }
  40:  
  41:         public static string[] EnumSubKey(RegistryKey Key)
  42:         {
  43:             try
  44:             {
  45:                 return Key.GetSubKeyNames();
  46:             }
  47:             catch (Exception ex)
  48:             {
  49:                 RegistryLastError = String.Format("{0}: {1}", ex.GetType().ToString(), ex.Message);
  50:             }
  51:  
  52:             return null;
  53:         }
  54:  
  55:         public static T GetValue<T>(string Path, string Name)
  56:         {
  57:             string lastError = RegistryLastError;
  58:  
  59:             try
  60:             {
  61:                 if (!String.IsNullOrEmpty(lastError))
  62:                     RegistryLastError = null;
  63:                 using (RegistryKey key = OpenKey(Path))
  64:                 {
  65:                     if (String.IsNullOrEmpty(lastError))
  66:                     {
  67:                         object value = key.GetValue(Name);
  68:                         if (value != null)
  69:                         {
  70:                             return (T)value;
  71:                         }
  72:                     }
  73:                 }
  74:             }
  75:             catch (Exception ex)
  76:             {
  77:                 RegistryLastError = String.Format("{0}: {1}", ex.GetType().ToString(), ex.Message);
  78:             }
  79:             finally
  80:             {
  81:                 if (!String.IsNullOrEmpty(lastError) && String.IsNullOrEmpty(RegistryLastError))
  82:                     RegistryLastError = lastError;
  83:             }
  84:  
  85:  
  86:             return default(T);
  87:  
  88:         }
  89:  
  90:  
  91:         public static bool SetValue<T>(string Path, string Name, T Value)
  92:         {
  93:             string lastError = RegistryLastError;
  94:  
  95:             try
  96:             {
  97:                 if (!String.IsNullOrEmpty(lastError))
  98:                     RegistryLastError = null;
  99:                 using (RegistryKey key = OpenKey(Path, false))
 100:                 {
 101:                     if (String.IsNullOrEmpty(lastError))
 102:                     {
 103:                         key.SetValue(Name, Value);
 104:                         return true;
 105:  
 106:                     }
 107:                 }
 108:             }
 109:             catch (Exception ex)
 110:             {
 111:                 RegistryLastError = String.Format("{0}: {1}", ex.GetType().ToString(), ex.Message);
 112:             }
 113:             finally
 114:             {
 115:                 if (!String.IsNullOrEmpty(lastError) && String.IsNullOrEmpty(RegistryLastError))
 116:                     RegistryLastError = lastError;
 117:             }
 118:  
 119:  
 120:             return false;
 121:  
 122:         }
 123:  
 124:  
 125:     }
 126:  
 127:     public class NetworkVisibility
 128:     {
 129:  
 130:  
 131:         public string Description
 132:         {
 133:             get;
 134:             internal set;
 135:         }
 136:  
 137:  
 138:         public VisibilityType NetworkScope
 139:         {
 140:             get
 141:             {
 142:                 if (String.IsNullOrEmpty(FullPath))
 143:                     return VisibilityType.Public;
 144:                 return (VisibilityType)RegUtil.GetValue<int>(this.FullPath, "Category");
 145:             }
 146:             set
 147:             {
 148:                 if (String.IsNullOrEmpty(FullPath))
 149:                 {
 150:                     return;
 151:                 }
 152:  
 153:                 VisibilityType visibility = (VisibilityType)RegUtil.GetValue<int>(this.FullPath, "Category");
 154:  
 155:                 if(value != visibility)
 156:                 {
 157:                     if (MessageBox.Show(String.Format("Do you want to change network context for {0} from {1} to {2}",
 158:                         this.Description, visibility, value), "Warning", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning) == DialogResult.Yes)
 159:                     {
 160:  
 161:                         if (!RegUtil.SetValue<int>(this.FullPath, "Category", (int)value))
 162:                         {
 163:                             MessageBox.Show(String.Format("Unable to change network {0} from {1} to {2}. Error: {3}",
 164:                                 this.Description, visibility, value, RegUtil.RegistryLastError),
 165:                             "Unable to do the operation", MessageBoxButtons.OK, MessageBoxIcon.Error);
 166:                         }
 167:                     }
 168:                     else
 169:                     {
 170:                         MessageBox.Show("No Change was made", "Information", MessageBoxButtons.OK,
 171:                                 MessageBoxIcon.Information);
 172:                     }
 173:  
 174:                 }
 175:             }
 176:         }
 177:  
 178:         public string FullPath
 179:         {
 180:             get;
 181:             set;
 182:         }
 183:  
 184:         public static IList<NetworkVisibility> GetList()
 185:         {
 186:             List<NetworkVisibility> nvl = new List<NetworkVisibility>();
 187:  
 188:             using (var reg = RegUtil.OpenKey())
 189:             {
 190:                 string[] list = RegUtil.EnumSubKey(reg);
 191:                 foreach (string k in list)
 192:                 {
 193:                     NetworkVisibility nv = new NetworkVisibility();
 194:                     nv.FullPath = String.Format("{0}\\{1}", RegUtil.NetworkRegPath,
 195:                         k);
 196:                     nv.Description = RegUtil.GetValue<string>(nv.FullPath, "ProfileName");
 197:                     nv.NetworkScope = (VisibilityType)RegUtil.GetValue<int>(String.Format("{0}\\{1}", RegUtil.NetworkRegPath,
 198:                         k), "Category");
 199:  
 200:                     nvl.Add(nv);
 201:  
 202:                 }
 203:             }
 204:             return nvl;
 205:         }
 206:  
 207:     }
 208:  
 209:     public enum VisibilityType
 210:     {
 211:         Public = 0,
 212:         Private = 1,
 213:         Domain = 2
 214:     }
 215:  
 216:  
 217: }

Comments (6)

  1. nzregs says:

    select the network in the settings app, hit the "properties" or "advanced properties" (depending on build), then use the toggle for "Find devices and content".  If you set it "On", its private.  If you set it "Off", its Public.

  2. Nzregs,

    Good luck trying this in Windows 10 builds 1049 and greater (1074 as of this writing). Anyway I added another solution pointed out by Regan Murphy using UI.

  3. mtherien says:

    Doesn't look like this works in the final release.  Selecting the network then clicking advanced properties just gives me a switch for Metered Connection.

    The Registry method still works.

  4. Mtherien,

    Run the application as administrator.

  5. It does not work on 10586.494 even if running as admin. It just crashes and I have to close it in task manager. This is on windows 10 core (home edition). It says:

    "---------------------------
    DataGridView Default Error Dialog
    ---------------------------
    The following exception occurred in the DataGridView:

    System.ArgumentException: DataGridViewComboBoxCell value is not valid.

    To replace this default dialog please handle the DataError event.
    ---------------------------
    OK
    ---------------------------
    "

    Here's a screenshot of the error:

    http://imgur.com/a/T4iEJ

    1. Don't forget to run as Administrator

Skip to main content