Python3 controls win10 connection wifi hotspots
I. basic knowledge
Introduction to 1.netsh:
Netsh (Network Shell) is a powerful command line tool for network configuration provided by the windows system itself. Netsh supports the following instructions:
This article mainly describes how to connect a new wifi (which can be a local area network or a public network) through the netsh command. Connecting to the local area network is mainly considered to facilitate the use of python to control the computer to connect the wifi module, and then you can play more applications, such as testing the performance of the WIFI module, completing the upgrade control of the equipment through the computer, and so on.
II. Operation steps
1. Create a user profile
(1) View the configuration files that exist on the current computer
Netsh wlan show profiles
(2) Export existing configuration files
Netsh wlan export profile key=clear
(3) modify the new configuration file
Now you need to connect to a new hotspot. Ssid is router_test and the password is 12345678.
You need to copy a file from the configuration file exported above and change the name to WLAN-router_test. The contents of the file are as follows:
two。 Add profile
Netsh wlan add profile filename=WLAN-router_test.xml
3. Connection test
Netsh wlan connect name=router_test
4.python connection testing
Python can call os.system () to execute system commands
# encoding = utf-8import osos.system ("netsh wlan connect name=router_test")