Windows 8 and 8.1 Forums

Test if WiFi is off/on in the Networks fly-out Win8.1 tab

  1. #1

    Posts : 3
    Windows 8.1

    Test if WiFi is off/on in the Networks fly-out Win8.1 tab


    I am putting together an app in vb6 (not a .Net coder as yet) that needs WiFi some of the time but not often and to preserve battery I would like to tell the user if WiFi is on when it needn't be.

    I found an excellent shortcut on this site that pops out the Networks fly-out pane (thanks for that!) but I would like to test if the WiFi switch is on or off.

    I found some code elsewhere that uses a WMIService call to get the name of the WiFi adapter if it is connected. That works but it returns a null string if either the WiFi is off or it is On but no WiFi connection has been chosen so it doesn't give me quite what I need.

    The code for getting the WiFi name is shown at the bottom of this message. I am thinking it is the wrong way to go as it relates to the adapter not the Windows switch but not sure.

    I had considered using the Airplane mode on/off that I also found on this site but I am having trouble getting back to my app after it runs and I would prefer the user to control it themselves anyway (hence the flyout)

    To see what changed I exported the registry on the device (HP Stream 7 running WIn 8.1) with WiFi switched on and then again having switched it off

    I then compared the text files and I found a flag that sounds promising called RFOff (it is 1 when WiFi is off and 0 when on). Am guessing RF is Radio something

    It is. however, deep in the CurrentControlSet001 under ....


    a couple of the values (there are many) are ...

    "DriverDesc"="Realtek RTL8723BS Wireless LAN 802.11n SDIO Network Adapter"

    Assuming I am right and that flag is the marker for the WiFi switch then how would I find it on any given machine (I have several to set up so assuming they wouldn't all have the same GUID for the WiFi device)

    All I need to do is test for it, not intention of setting it. If WiFi is On then I can pop out the flyout pane

    Any help gratefully received!



    Here is the code for detecting the WiFi name.

    bIsWifiOn = False

    On Error Resume Next
    sComputer = "."
    Set oWMIService = GetObject("winmgmts:" & sComputer & "\root\CIMV2")
    Set colWifi = oWMIService.ExecQuery("Select * From Win32_NetworkAdapter Where NetConnectionID =" & "'" & sGetWirelessName & "'" & "and PhysicalAdapter='True' ")

    Dim sSt As String
    Dim sSi As String

    If Not colWifi Is Nothing Then
    For Each oWifi In colWifi
    If oWifi.Netconnectionstatus = 2 Then
    If Trim(oWifi.Name) <> "" Then bIsWifiOn = True
    End If
    End If

      My System SpecsSystem Spec

  2. #2

    Doesn't the Windows OS already do this from the Desktop aspect via the Notification Tray Icon on the Taskbar?

    Then, it's all a matter of presenting that information discreetly in the Modern aspect. BTW, I've stayed away from the Modern aspect. Still, I don't think the presentation can be done, in a non-jarring way. I guess that's the challenge: find a way to intrude upon an app running full-screen to say, "Turn off the WiFi!"
      My System SpecsSystem Spec

  3. #3

    Central IL
    Posts : 3,468
    Linux Mint 17.2

    Why recreate the wheel? This feature is already available in all editions of Windows.
      My System SpecsSystem Spec

  4. #4

    Posts : 3
    Windows 8.1


    Thanks for your replies, sooner and broe.

    sooner - It does show the status in the tray yes but my app is full screen (on the desktop) and the taskbar isn't visible. Not sure what the Modern aspect is, is that another term for the Metro interface? If so then I am not using that.

    broe - I am not trying to recreate the wheel, I am not sure what feature you are referring to?

    I want my app to know if WiFi is on or off so I can control what options the user has and if they are in a part of the app where WiFi isn't needed (and they will be in that bit for several hours) then I want the app to tell the user if WiFi is on to remind them to switch it off

    Is there some way to tell if the Windows WiFi switch is on or off from the registry or something else I can test with VB


      My System SpecsSystem Spec

  5. #5

    Usually, when someone uses the term "app" or "application" as it relates to Windows 8, I associate it with the Modern/Metro side. "Programs" run in Desktop mode.

    Back to the topic at hand, as broe23 and I try to say, the Windows OS already 'streams' that info, and presents it in the Notification Tray. Then, it's just a matter of finding that stream and tapping into it. That knowledge is way 'above my pay grade', as the saying goes.

    Thinking outside the box, wouldn't it be better to have an option of running your 'app' in Desktop mode in a full-sized window? Then, the taskbar is always in view.

    Or your 'app' opening splashscreen can offer a reminder to turn off the WiFi.
      My System SpecsSystem Spec

  6. #6

    Posts : 3
    Windows 8.1

    sooner - fair enough, was just being lazy with my terminology. It is a program. It runs in Desktop mode.

    WiFi does appear in the system tray but my program when running full screen is over the top of the taskbar. Not sure why (prob cos it is VB6) but I don't really want to lose all the space the Taskbar takes up anyway just to show the one little icon that shows the WiFi setting. It is only a 7 inch tablet so space is quite tight.

    Mainly I want to draw my user's attention to their WiFi setting and I can do that more obviously in the program.

    They will need WiFi on when they start the program for a bit, then not for ages and then on again towards the end of the session.

    I can rely on them to do as asked and switch it on/off but I wanted a way of checking that to give a reminder if it gets missed.

    I want to give the battery life as long a run as possible and WiFi off is an easy way to help that

    I can live with trusting them if I have to but what I want to do is detect the WiFi status. I was hoping someone knew a way. "Tapping into the stream" as you put it.

    Am fairly sure the registry key I found is relevant but can't see how to find it on just any machine. Hoping there is something easier.
      My System SpecsSystem Spec

Test if WiFi is off/on in the Networks fly-out Win8.1 tab
Related Threads
Wifi - No networks found in Network & Sharing
Ok so here's the thing. Installed W8 pro with media centre (x86). Everything worked fine, connected to internet wirelessly no problem. Then after a couple of days I get no networks found out of the blue for no apparent reason. Here are the facts: Router/internet connection is fine, other...
I read bunch of articles on how to remove a Wifi profile.. However I have problem with networks which aren't in profiles (I only have 1 profile and its my home network).. I have currently 7 networks when I click on the Wifi icon in the task bar. they are from people living around me I guess....
Hey, Windows 8.1, Broadcom 802.11n network card&driver, My computer stopped recognizing the wireless networks at my university - oddly enough, some other networks elsewhere can be found (although I cannot test if I can actually connect to them, since they are passworded/not mine). I...
Hello- I am trying to troubleshoot a network connectivity issue for my Mom & Dad's laptop. It is an HP 64-bit running Windows 8.1. Up until this morning, it was able to connect to wi-fi. My mother was on the internet with no problems. They have my-fi with AT&T and my dad's laptop and tablet...
Hi, We have internet provided through the place we live for free. It is broadcasted as an unsecured wifi network. I can connect to the internet with no problems with my windows 7 computer. I recently got a windows 8 computer. I this computer has trouble staying connected to the unsecured...
Recently upgraded my laptop to Windows 8.1 and I cannot see any 5Ghz wireless networks, even though they are present (I am able to successfully see and connect using other devices including a Windows 7 laptop). I can see 2.4 Ghz networks and connect no problem. I have upgraded the wifi driver to...
Hello, My laptop is few months old HP Pavilion g6 OS: Windows 8 uses a ralink rt5390r 802.11bgn wifi adapter. The wifi was working just fine suddenly it stopped. It detects my home network but every time it tries to connect ends up "unable to connect to this network". It connects to my...
Eight Forums Android App Eight Forums IOS App Follow us on Facebook