Click here to Skip to main content
15,867,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have been searching the internet for weeks now.
Is there a way I can connect to a network/router/access point through VB.NET?
I don't really care if the program needs administrative privileges.
I have already made a program which lists the access points in range.
The purpose of my program is to, when in range of a BT Openzone or FON hotspot, to connect to it.
I am at the point where the program has found a access point in range.
Now, I am not that good with APIs, so please if you refer me to one can you give me more or less step by step instructions what to do with it (eg. put this file in the app directory, add a reference to this file)

Here is my current code:
VB
Private Function RetrieveNetworks()
Dim proc As New Process
proc.StartInfo.CreateNoWindow = True
proc.StartInfo.FileName = "netsh"
proc.StartInfo.Arguments = "wlan show networks mode=ssid"
proc.StartInfo.RedirectStandardOutput = True
proc.StartInfo.UseShellExecute = False
proc.Start()
Return (proc.StandardOutput.ReadToEnd())
proc.WaitForExit()


I have managed to filter the output so I get a perfectly clean list of SSIDS.
Any help and I would be very grateful.
Posted

1 solution

You're not really writing a program to get a list of SSIDs and connect to them. If that was the case, you'd be using the Wireless Network API.

You're writing a program to ask another program what the list of SSIDs are.

Well, you can use the same technique to net NETSH to connect to another SSID. The command would look something like:
netsh wlan connect name={profile name} ssid={ssid to connect}

Of course, you need the profile name first. This means you have to use the command
netsh wlan show interfaces

and parse the result to get the Name, Radio type and Profile fields. The radio type will give you which interface to try and use. After all, you can't connect to an 802.11g SSID on a Bluetooth interface.

Once you have that table, you can use the Connect command as layed out above with the information in the table.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900