Windows 7 as WiFi Access Point

OK here is the deal: You have a wired connection to the Internet e.g. in a hotel room but your fancy new smart phone, iPad etc. just has WLAN connection. Until now you had three possibilities:

  1. Use your 3G connection
  2. Use Bluetooth or crappy wired connections
  3. Stay offline, go the hotel bar and get drunk you damn geek!

Well since all modern notebooks do have a WLAN card built in, why not use this card as an access point? The average Linux guy is now really LOLing but for us Windows users this just was a dream. Now Microsoft implemented some nice command line tools to turn your WLAN card into an access point. You can find the information here:

http://blogs.technet.com/b/sieben/archive/2009/09/24/virtual-wifi-macht-windows-7-zum-access-point.aspx

To make the story short the command is:

netsh wlan set hostednetwork mode=allow ssid=”YOUR WLAN” key=”YOUR KEY” keyUsage=persistent

Followed by

netsh wlan start hostednetwork

Since a Windows User is GUI-oriented, i created a small app which does the job for you:

Windows Access Point

as always you can find the source code here:

Windows Access Point Source

The app provides you some nice (undocumented) command line options

  • start -> Starts the WLAN you entered last
  • stop -> Stops the WLAN
  • start route 192.168.0.0 255.255.255.0 172.16.1.0 -> Adds a route after start (e.g. for VPN-Connections)

If you want to make your own app, create two text fields and two buttons and i’ll provide you the methods :)

private string SetWLAN(string SSID, string key)
{
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = "netsh.exe";
p.StartInfo.Arguments = "wlan set hostednetwork mode=allow ssid=\"" + SSID + "\" key=\""+ key +"\" keyUsage=persistent";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.CreateNoWindow = true;
string sOutput;
p.Start();
sOutput = p.StandardOutput.ReadToEnd();
p.WaitForExit();
p.Close();
return sOutput;
}
private string StartWLAN()
{
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = "netsh.exe";
p.StartInfo.Arguments = "wlan start hostednetwork";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.CreateNoWindow = true;
string sOutput;
p.Start();
sOutput = p.StandardOutput.ReadToEnd();
p.WaitForExit();
p.Close();
return sOutput;
}
private string StopWLAN()
{
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = "netsh.exe";
p.StartInfo.Arguments = "wlan stop hostednetwork";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.CreateNoWindow = true;
string sOutput;
p.Start();
sOutput = p.StandardOutput.ReadToEnd();
p.WaitForExit();
p.Close();
return sOutput;
}

Note: This is just a simple GUI for the NETSH-tool. If you are really interested in serious Virtual Wifi programming check this one out:

http://msdn.microsoft.com/en-us/library/dd815243%28v=vs.85%29.aspx

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">