admin管理员组

文章数量:1571937

你有100台win电脑,需要连接上WiFi,你又不想一台一台输入密码,那么怎么写脚本自动连接呢

首先必须已知 WiFi 名,WiFi SSID,及密码

具体怎么查搜索一下方法就可以

编写 xml 配置及 bat 脚本执行

<?xml version="1.0"?>
<WLANProfile xmlns="http://www.microsoft/networking/WLAN/profile/v1">
	<name>你的 WiFi 名字</name>
	<SSIDConfig>
		<SSID>
			<hex>你的 WiFi SSID</hex>
			<name>你的 WiFi 名字</name>
		</SSID>
	</SSIDConfig>
	<connectionType>ESS</connectionType>
	<connectionMode>auto</connectionMode>
	<MSM>
		<security>
			<authEncryption>
				<authentication>WPA2PSK</authentication>
				<encryption>AES</encryption>
				<useOneX>false</useOneX>
			</authEncryption>
			<sharedKey>
				<keyType>passPhrase</keyType>
				<protected>false</protected>
				<keyMaterial>你的 WiFi 密码</keyMaterial>
			</sharedKey>
		</security>
	</MSM>
	<MacRandomization xmlns="http://www.microsoft/networking/WLAN/profile/v3">
		<enableRandomization>false</enableRandomization>
	</MacRandomization>
</WLANProfile>

将上面的 xml 文本保存到文件 wifi-profile.xml

@rem 导入配置
netsh wlan add profile filename="./wifi-profile.xml" user=all

@rem 连接 WiFi
netsh wlan connect name=你的 WiFi 名字

pause

将上面的 bat 保存到文件 wifi-connect.bat,跟 wifi-profile.xml 文件同目录。

再将两个文件内中文 WiFi 相关配置改成自己的。
双击 wifi-connect.bat 即可自动输入密码连接WiFi。
文件名可以随意起,只要脚本能导入即可。

执行结果如下:


参考:
https://qr.ae/pyKTh2
https://blog.csdn/panjunnn/article/details/112356954

本文标签: 命令行脚本输入密码Windowsnetsh