简体   繁体   中英

How do I programmatically disable Wi-fi Sense in Windows 10?

Windows 10 has a new feature called Wifi Sense . The feature connects WLAN adapter to any open hotspot in vicinity. It also shares WLAN passwords with friends over Facebook. According to our tests it:

  • creates new persistent WLAN profiles if there is a hotspot in vicinity (ie an open hotspot or hotspot for which it has password from friends).
  • keeps reordering profiles in an order it deems to be best.

I found several answers how to disable Wifi Sense via Windows UI: eg here . However, no answer really disabled creation of new profiles for open hotspots. Is there a way how to disable Wifi Sense completely? Preferably programmatically.

TL;DR : There are undocumented registry values that can disable some features of Wifi Sense. The values are located in key HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\WcmSvc\\wifinetworkmanager\\features and are named WiFiSenseCredShared and WiFiSenseOpen . First controls whether Wifi credentials are shared second controls whether Wifi Sense creates new profiles for open hotspots. Default values (at least on my machine) for both are 1. Change them to 0. WcmSvc service contains implementation of Wifi Sense and needs to be restarted after changes in registry are made. I tried just sending SERVICE_CONTROL_PARAMCHANGE to WcmSvc via ControlService API but I got ERROR_ACCESS_DENIED so full service restart is necessary until MS publishes some public API. Note that because the values are undocumented, MS may change their location or even remove them in next versions of Windows.

Edit : The values recommended above stopped working with the newest builds of Windows 10. However I found out that Wifi Sense configuration state is stored in value HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\WcmSvc\\wifinetworkmanager\\features\\S-1-5-21-774371734-2276234837-1234541976-1000\\FeatureStates . Note that key name S-1-5-21-774371734-2276234837-1234541976-1000 might vary for different machines. The value itself is a bitmask with following semantics:

enum EWifiManagerFeatureStates
{
  CONNECT_OPEN_HOTSPOTS = 0x0001,
  CONNECT_NETWORKS_FROM_CONTACTS = 0x0040,
  CONNECT_PAID_HOTSPOTS = 0x200,
}

These bits have to be set to 0 disable Wifi Sense completely. I was not able to find meaning of the remaining bits, but others can experiment with setting them to 0 too.

Long story : For interested people here is a short description how I found the undocumented registry values. It might help others find more undocumented registry values.

First I guessed there ought to be an undocumented registry setting that is able to turn WifiSense off. So I installed Process Monitor tool which is able to list all registry accesses for all running processes. I opened Windows Settings UI at Network/Wifi/Advanced Wifi Settings and changed settings related to Wifi Sense. Then I looked at Process Monitor output to see which parts of registry were accessed. I filtered the output to RegSetValue to see only writes and reduce noise of other registry operations.

I saw several writes to values of key HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\WcmSvc\\wifinetworkmanager\\features\\S-1-5-21-774371734-2276234837-1234541976-1000

When looking at the key in regedit I didn't find anything interesting there but there were two very suspicious values in its parent key (...\\wifinetworkmanager\\features). The values are DWORD (numbers) and are named WiFiSenseCredShared and WiFiSenseOpen. Both were set to 1. I set them to 0 and restarted WcmSvc service so that new values would be reread. After this Wifi Sense was turned off. I was able to delete profiles created by it and no new open profiles were created.

Use this script in cmd.exe to disable this feature ( the source ) in recent Windows 10 builds:

for /f %%A in ('reg query "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\WcmSvc\\wifinetworkmanager\\features"^|find "S-1"') do (reg add %%A /v FeatureStates /t REG_DWORD /d 828 /f)

Note: this is inside CMD-file syntax. Use %A instead of %%A if you plan to use it inside command interpreter (not cmd-file).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM