2

I know that I can open the "Network Connections" control panel location by executing "ncpa.cpl", but that is not good enough for my application. I want to actually open the list of available networks (the equivalent of clicking on the "Wireless Network Connection" option on the "Network Connections" page.

I have searched high and low for a solution, and I have found nothing. The only reason I even need to do this is because windows doesn't update the available networks in a timely fashion unless you open the "Wireless Network Connection" list. I can sit here and use "netsh wlan show networks" all day and it will not detect new networks until I simply click on the "Wireless Network Connection". I don't even have to hit the refresh button - I only bring up the native list.

I have had mixed results by disconnecting (netsh wlan disconnect) and waiting for several minutes, but this is unacceptable.

I'm trying to incorporate a handy feature in a VB.NET tool that will filter the available WiFi networks and allow the user to connect to one by selecting it in a listview and pressing a "connect" button. I have the code working just fine, but I am limited by this insanely slow refresh rate. If I simply click on the internet access applet in the tray my list will refresh, but it kind of defeats the point. I have already done a fair bit of work to get around netsh's limitation of needing a profile to connect to a network, so this is a frustrating development.

If I can simply run the applet, even in the background, it would solve this problem. If that's not possible, is there a service that I can refresh/restart without admin privileges that would cause windows to get an updated list? It's kind of ridiculous that netsh does not actually update the list...

Edit:

And in case I am asking an XY problem, I just want to be able to get an accurate and current list of available WiFi networks from within a .NET application. I'd also like to be able to connect to said network from within .NET, although my netsh "solution" does the job just fine as long as I can get an SSID. If you could also explain to me why .NET/Java/etc higher-level languages can't provide a platform-agnostic abstraction of the network interface I would give you bonus points. I am aware of the native API solution, but that seems to me like complete overkill for my application (and is beyond my skillset/time capabilities right now). If there is a good tutorial/document about including small native code modules in a .NET solution I am all ears, though.

Thanks in advance

DrEsperanto
  • 167
  • 9
  • Ĉu vi havas ["XY Problem"-on](http://meta.stackexchange.com/questions/66377/what-is-the-xy-problem)? I don't have an answer, but I wonder if the Win32 API's [WlanScan function](https://msdn.microsoft.com/en-us/library/windows/desktop/ms706783(v=vs.85).aspx) triggers the refresh; if so, there is a [C# wrapper for it](http://managedwifi.codeplex.com/) which could be included in a VB.Net project, or ported to VB.Net. (And a [C example](http://www.codeproject.com/Tips/447580/Demonstration-of-Wlan-APIs-from-MSDN)) – TessellatingHeckler Jun 25 '16 at 02:45
  • @TessellatingHeckler Hah, ŝajnas ke mi eble havas tian problemon, sed mi jam sciis pri tiu "solvaĵo". – DrEsperanto Jun 25 '16 at 05:37
  • @TessellatingHeckler I suppose I'll have to dig into the native interface to do it "right". It just seems wrong to have to do this when .NET seems to have functionality for everything else under the sun. I don't buy that returning a list of available wifi networks and/or connecting to networks is somehow too platform-specific for a general framework. If they were shooting for security they already lost when I can connect to any unsecured network as long as I wait a few minutes for the list to update on its own... – DrEsperanto Jun 25 '16 at 05:48
  • Have you tried this ? http://managedwifi.codeplex.com/ – sodawillow Jun 25 '16 at 07:48
  • I don't see how this is a duplicate when you look at my actual question. The 3rd-party managed library is not an acceptable solution, and does not answer the question of if the native WiFi applet can be opened programatically. I asked the question because the "duplicate" was not what I was looking for. – DrEsperanto Jun 26 '16 at 21:12
  • 1
    I have now finally found my own answer. This applet is started by running the not-so-aptly named "van.dll" with the "RunVAN" entry point. In the shell this is simply "rundll32.exe van.dll,RunVAN", and from .NET within Powershell (easier to test) I did: [System.Diagnostics.Process]::Start("rundll32.exe", "van.dll,RunVAN") – DrEsperanto Jun 28 '16 at 19:52

0 Answers0