Create a virtual wifi router with internet on Windows 7

Status
Not open for further replies.

Harfeg

Distinguished
Jul 16, 2010
12
0
18,510
Hello all,

Having just spent the last three hours getting it to work I thought I would share my discoveries with the wider community, since there are lots of tutorials but most leave out a crucial fact or two.

----------Premise:
You have a cabled connection to the internet on your Windows 7 computer but you want to share it wirelessly with other wireless devices which may not recognise an ad-hoc connection.

In my case I live in student accommodation that has one ethernet port in each room. It is currently connected to my desktop (which also has a wireless card) and I would like my laptop and phone to be able to connect to the internet and share files with each other. The problem is my android doesn't recognise ad-hoc networks

----------Solution:
Create a Virtual Wifi Hotspot using a semi hidden feature in Windows 7. It looks just like a normal router WLAN but uses the hardware an ad-hoc would (i.e your wireless card). I'll also explain how to get the connection to start automatically when your computer does.

You can also download "Connectify" which uses this feature and actually has a user interface. I like to keep my startup software to a minimum though so I prefer doing it manually.

This only works with some wireless network cards but it works on my 4 year old card so give it a go.

----------How:

Initial setup

0) If you want to share files make sure "network discovery" and "file sharing" are turned on in advanced sharing settings. If you don't have a password on your computers turn off "password protected sharing" as well, since it can't seem to tell that you don't have one, and thinks you typed it in wrong. Though it doesn't SEEM necessary being part of the same workgroup can't hurt (right click computer in the start bar, properties, change settings)

1) Start a command prompt with admin rights

- Type: netsh wlan set hostednetwork mode=allow ssid=nice name key=sensible password keyUsage=persistent

obviously replace "nice name" and "sensible password" to your own taste, then press enter
N.B the password needs to be at least 8 characters long

("keyUsage=persistent" isn't necessary according to the command prompt documentation but I put it in for completeness. To see the command prompt documentation the only reliable way i've found is to try and set a password less than 8 characters long)


2) Go to "Network and Sharing centre", "change adapter settings". If all is well you should see a new connection that has Microsoft Virtual WiFi Miniport Adapter written underneath it. That and a nice red X next to it.
Rename the connection to something you will recognise later on. Virtual Wifi worked well for me.

3) Right click on your Ethernet connection. Click Properties then go to the sharing tab. There is an unhelpful GUI on this screen. You must click on the drop down menu and select your Virtual Wifi BEFORE clicking on the top check box, otherwise the drop down menu becomes an uneditable text box. The menu tells Windows which wireless network to share the connection with.

4) Now click settings and make sure all the boxes are ticked (top one reads "FTP Server")

Starting the connection

5) Back to the command prompt

-Type: netsh wlan start hostednetwork

Press enter. It should then say "the hosted network was started"

Go to the Network and Sharing and check that both the Ethernet and Virtual Wifi have "internet access" written next to them. Set both to a Work or Home network as well (Work won't ask for Homegroup details)

That's it, you have successfully made a Virtual Wifi hotspot router thing. Now just connect you phone/laptop in the normal way. ( I recommend ES file explorer if you have an android. I can get files from the shared folders on both my computers with my phone using it, copy/paste multiple files... awesome, and free (with ads))

----------Restarting the network at startup:

1) Open up notepad
-Type: netsh wlan start hostednetwork
pause

the save it as "something.bat"

2) Run it with admin rights just to check if it works. Leave the pause in for now

3) Type "task" into the start menu and click on "Task Scheduler". Click on "Create Task" over in the right hand panel. Name it something and (IMPORTANT) check the box that says "run with highest privileges".

4) Go to the "Triggers" tab, New, and select "at log on" from the dropdown menu. Give it a delay of 30 seconds if you like everything else to be loaded first.

5) Go to the "Actions" tab and browse to the batch file you just made. If you want to be really neat make a shortcut of the batch file and tell it to start minimised, and make Actions open the shortcut instead. (otherwise you might see a black flicker every time the network starts, but it is just a flicker)

6) "OK" your way out of that window. On the main "Tasks" window, left hand side, click on the Task Scheduler Library folder. Find your task in the middle panel, click once, then on the right click run to test it.

If it works then restart your computer to make sure it happens automatically - once your sure of that just go to the batch file, open it in notepad and take out the "pause" command. Your all done.



P.S If you have a problem connecting your devices just get windows network diagnostic tool to have a look at it. For some reason my laptop had DHCP disabled on it when i tried to connect first time but the diagnostic tool sorted it out.

Hope this helps someone and doesn't cause to many headaches.
 

TechnoPhil

Honorable
Jul 15, 2012
1
0
10,510
Thanks so much for the clear guide, it's exactly the problem I'm having.

I've followed the guide step by step and my Samsung Tab can see the wireless connection, I can connect to it and all appears well.... however I can't access the internet!

I've been trying to get this working all day and I've exhausted forums and tried everything I can find, do you have any other ideas for me?

I have a windows 7 pc with a Realtek RTL 8188CE Wireless LAN 802.11n PCI-E NIC wifi card.

I've been using this website (http://www.virtualaccesspoint.com/) to start and stop with virtual access point to save time (it seems to do the same as your guide) and I'm now stumped.

Any help MUCH appreciated!
 

ashvyn

Distinguished
Sep 29, 2011
1
0
18,510


Harfeg, you are simply too amazing. An awesome solution you have put in here, where we don't need to play with the Root settings of our Android devices (the problem that I was facing) to connect them to the Internet by sharing my computer's LAN with it. Amazingly well written solution you given, this coming from a Senior Technical Writer with a large IT Company here in India. Thanks a lot man. Keep up the good work.
 

ZatoIci

Honorable
Dec 30, 2012
1
0
10,510
Excellent post. I wonder about my laptop going to sleep if it's only being used as a WiFi basestation. Will Internet activity going thru the laptop count to keep it awake? Or should I set the powerdown to Never for the times the laptop is sitting there using wall power?

FWIW, we are about to spend a week in a resort with Ethernet in each suite, but no WiFi. We have an iPad, which of course lacks an Ethernet port. I plan to leave the virtual WiFi on all day for the iPad using non-skiers while I'm out on the mountain.
 

viralshah

Honorable
Feb 22, 2013
2
0
10,510

 

viralshah

Honorable
Feb 22, 2013
2
0
10,510
 

Harfeg

Distinguished
Jul 16, 2010
12
0
18,510
Wow I gave this thread up for dead last time I looked at it 6 months ago. Thanks for all your kind words about it.

Problems:
Firstly the the third last word of my initial post is the wrong kind of to (should be too). Not good.

viralshah, hope I can still help with your problem if it's not too late. I think you described the solution in your post. You put keyUsage=persistent after key=mypassword without a space. I reckon the problem is that your network password is actually "mypasswordkeyUsage=persistent". keyUsage=persistent isn't necessary for the command to work which is why command prompt accepted it. either enter that password or put a space and that should set you straight.

For everyone else the only thing I can suggest is that you make sure the LAN is fully working on the host computer, have a look at step 5 and make sure both connections have internet access as described there. If you are definite on that use network diagnostic on the computer you trying to connect with (it really is very good). Assuming you followed the instructions in full of course.

One thing that might help is make sure your ssid and key have no spaces in, that might be causing trouble (it might not haven't tested but it's worth a go)

If you can't figure it out I think the best thing to do undo everything with the command below, restart, and try again, it's shocking how often a restart and redoing the steps fixes things.

netsh wlan set hostednetwork mode=disallow

Hope that helps
 

Paul162

Honorable
Jun 28, 2013
1
0
10,510
Great tutorial, but I had an extra issue so I thought I'd report my findings here.

My situation is the following: I have an all Windows 7 LAN, with one desktop machine connected to the internet via USB (cable modem). I recently upgraded my old HTC phone to a Samsung S4, and the new phone cannot 'borrow' an internet connection through USB (reverse tether) like the HTC one could, hence my need to set up a managed WiFi hotspot (I don't want to bother rooting my phone to get it to connect to AdHoc WiFi).

Now my problem is that my gateway desktop has no wireless card, so I need to share the internet connection via a laptop. But a shared connection in windows forces the IP address of the gateway to be 192.168.137.1. Because my network has two share points (the desktop gateway to the LAN, and the laptop gateway between LAN and WIFI) I could not share the connection on the laptop. I got the message: "Internet Connection Sharing cannot be enabled. A LAN connection is already configured with the IP address" every time I got to the 'share' stage described above.

The solution involved getting into the registry and changing the default IP address for a shared connection gateway on the laptop. See http://support.microsoft.com/kb/230148 for descriptions on what keys to change for both XP and Win7. Note that I ONLY had to change the IP address for ScopeAddress (not StandAloneDchpAddress). I change it to 192.168.140.1 (the subnet mask is always 255.255.255.0 and cannot be changed).

Then on my WiFi connection settings I had to change the IPV4 properties and set "Use the following IP address" (192.168.140.1, subnet 255.255.255.0) and set the 'Use the following DNS Server' to '192.168.140.1'.

Once I had done that, I could immediately share my LAN internet with my WiFi, and the phone would connect to the WiFi automatically (once entering the password of course) and obtain its own IP without problems.

Hope this is some help.
 

Polochamps

Honorable
Mar 14, 2013
1
0
10,510
Thank you so much Harfeg for your detailed tutorial.

PS: For those having problems with wifi names w/spaces, you just enclose the name with - "desired name"

Ex. netsh wlan set hostednetwork mode=allow ssid="nice name" key=sensible password keyUsage=persistent
 

Leandro Leveron

Honorable
Jun 30, 2013
1
0
10,510
For those who have problems connecting your android phone.. follow this simple steps:

First disconnect from the network .. go to wifi settings .. from there navigate to advanced wifi settings .. check the "Use Static Ip" then come back and enter password and connect to the wifi again .. now while it tries to connect .. go to advanced again and remove the check box and come back and see you will be connected !!!!
Funny fix ! Worked for me many times !!!
 
Status
Not open for further replies.