dewijones92
dewijones92

Reputation: 1359

How do I connect to a hidden SSID in Windows 10 programmatically?

I have spent ages on this and I am stuck.
I am trying to connect to a known hidden SSID programmatically.

I am using the following code

await firstAdapter.ScanAsync();

WiFiAvailableNetwork network = firstAdapter.NetworkReport.AvailableNetworks.FirstOrDefault(n => n.Ssid == ssid);

The problem is I need to supply as a first an object of type WiFiAvailableNetwork but AvailableNetworks only brings back non-hidden SSIDs.

public IAsyncOperation<WiFiConnectionResult> ConnectAsync(WiFiAvailableNetwork availableNetwork, WiFiReconnectionKind reconnectionKind, PasswordCredential passwordCredential, String ssid)

https://learn.microsoft.com/en-us/uwp/api/windows.devices.wifi.wifiadapter.connectasync#Windows_Devices_WiFi_WiFiAdapter_ConnectAsync_Windows_Devices_WiFi_WiFiAvailableNetwork_Windows_Devices_WiFi_WiFiReconnectionKind_Windows_Security_Credentials_PasswordCredential_System_String_

The above code works perfectly with non-hidden SSID's.
Is there an API to connect to a hidden SSID?
Thanks

Upvotes: 1

Views: 1113

Answers (1)

Homertax
Homertax

Reputation: 651

If available, the hidden network should be in the firstAdapter.NetworkReport.AvailableNetworks list.

As the SSID is hidden, the Ssid property of WiFiAvailableNetwork for the target network will be "".

You could make an assumption here and attempt to connect to it using:

await firstAdapter.ConnectAsync(networks.First(x => x.Ssid == ""), WiFiReconnectionKind.Automatic, "password", "knownSSID");

Upvotes: 5

Related Questions