This is a rewrite of wifi-hosted-network-cmd. The rewrite is using Powershell instead of CMD for future compatibility.
I decide to rewrite the script in Powershell because of the following reason.
-
Batch scripting is legacy way to do things.
While the batch scripting is working fine, I want to learn something new. Powershell gives a new way to interact with Windows scripting environment.
-
Future proof.
Somewhere in the future, batch scripting may be dropped. This rewrite will hopefully make this project survive in the future.
-
Easy to debug.
Powershell makes a great environment to write and debug script. I want to make use of those debugging feature to help me write the script.
My concept of a good script are below.
-
The script should be easy to use.
[x] Good brief about what the script does.
[x] Good user interaction.
-
The script should perform as intended.
[x] Less actions needed to get the job done.
[x] Self diagnostic can be performed to satisfy requirements of actions performed.
[x] Good explanation on errors.
Hosted network is Windows implementation of software-based wireless access point. It's different from Ad-hoc networking. Hosted network is recognized as wireless infrastructure and available for most mobile devices, including Android and iOS.
Hosted network can be set up manually via cmd
or powershell
with administrator rights,
using the following commands.
- Configuration.
netsh wlan set hostednetwork mode=Allow ssid="Wireless AP" key="My Secret Key" keyUsage="persistent"
- Starting hosted network.
netsh wlan start hosted network
- Stopping hosted network.
netsh wlan stop hostednetwork
To run this script, you need Powershell to allow running script file.
- Launch Powershell as administrator. Type the following command to show current
script execution policy. It's likely to be
Restricted
for the first time.
Get-ExecutionPolicy
- In the Administrator Powershell window, type the following command to allow running script.
Set-ExecutionPolicy Unrestricted
If you are sure to run the script, make an approval by pressing y
. If you don't intend to run
the script, press n
to decline.
- Now, you can run the Powershell script. Remember, if you don't trust me, you SHOULD open the script file via Powershell ISE by clicking File --> Open or open it in your text editor prior to running. Review the script and make necessary editing as you need.
If you are paranoid and doesn't trust me, this is a brief explanation of what this script does.
-
Detecting administrator rights to perform hosted network configuration and tasks.
- If administrator rights is unavailable, the script will abort.
-
Detecting whether the wireless driver supports hosted network.
- If the driver doesn't support hosted network, warn user and abort.
-
If the wireless driver supports hosted network, prompt the user for configuration.
-
SSID (Wireless access point visible name)
-
WPA2 passphrase
-
-
After configuration has been set up, prompt the user to do wifi related tasks.
-
Starting and stopping the hosted network.
-
A guide to enable internet connection sharing is shown on successful startup.
-
A warning is displayed if the wireless device is disabled or powered off.
-
-
List connected stations.
- Displayed by showing MAC-Addresses
-
Changing hosted network configuration.
- SSID & WPA2 passphrase.
-
-
When the hosted network is not needed anymore, user can stop it and exit the script.
Currently, Windows hosted network has the following limitations.
-
Wireless mode can't be changed.
You are stuck with WPA2-PSK mode. This is considered good for personal use, but may be unsuitable for use with Enterprise which needs stronger wireless protection. A passphrase is always required to get the hosted network running.
-
No configuration of wireless operating mode.
Windows hosted network operates at half-N speed (65 mbps). The achieved wireless throughput may be less than that due to latency and other causes. You won't be able to utilize all wireless chip potential due to this limitation.
-
Limited number of connected clients.
Since Windows client OS is designed that way, there is a limitation of how many clients can connect at the same time to the configured hosted network.
Currently, there is no way to overcome those limitations.
If you want a full featured wireless solution, you may get yourseft a recent wireless router or use Host AP implementation such as HostApd which is available on GNU/Linux or BSD distributions.
All bugs should be reported via issue tracker. Patches and pull requests are greatly appreciated.
MIT license, see LICENSE