Creating a virtual wi-fi router in Windows 7

This advice was written by harfeg and was found useful by several posters.

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.