-1

I successfully list out remembered wifi in my windows profile using Native WI-FI from Nuget package. This is my code load list of WI-FI

 Private Sub loadWifi()
    listWifi.Items.Clear()


    Dim wlan As WlanClient = New WlanClient()
    Dim connectedSsids As List(Of String) = New List(Of String)()

    For Each wlanIface As WlanClient.WlanInterface In wlan.Interfaces

        For Each profileinfo As Wlan.WlanProfileInfo In wlanIface.GetProfiles()
            listWifi.Items.Add(profileinfo.profileName)
        Next
    Next

End Sub

My intention is how can I get the selected WI-FI from combo box listWifi and connect to the network.

Then im using netsh command to connect with the network. Take from the combo box. It does not work

Private Sub ConnectTo(ByVal name As String)
    Dim p = "netsh.exe"
    Dim sInfo As New ProcessStartInfo(p, "wlan connect " & name)
    sInfo.CreateNoWindow = True
    sInfo.WindowStyle = ProcessWindowStyle.Hidden
    Process.Start(sInfo)

End Sub
  • Bluntly, what is the point of showing us a code snippet the ask for help with something else. Update your question with your best attempt to switch network. Would also suggest using the search, there was a question a couple days along a similar vain. – Hursey Jun 24 '22 at 03:05
  • @Hursey update my question already – Shahrul Amir Jun 24 '22 at 03:29

1 Answers1

0

I made decision to use SimpleWIFI API rather than Native since it will cause my application to crash (Exception: cannot be marshaled error).

To connect the network just simply netsh wlan disconnect first and connect the network using codes above. It works but with minor error (not all available network scanned sometimes) rather than my apps to close itself unexpectedly.

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 19 '22 at 14:11