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:
- Use your 3G connection
- Use Bluetooth or crappy wired connections
- 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:
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:
as always you can find the source code here:
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
About