[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

NETSH创建网络连接配置

本帖最后由 /zhqsystem/zhq 于 2023-10-28 14:09 编辑

不是所有都这么设置,是样本[代码更新细节优化],需要就拿走,不过也只是安装系统用一次,部分地方根据自己的设置进行优化
[code]@Echo Off&Color 0e&SetLocal EnableDelayedExpansion&cd/d "%~dp0" set "[title][Name]=添加无线网络SSID
if /i not "%~f0"=="%~dp0%[Title][Name]%%~x0" ren "%~f0" "%[Title][Name]%%~x0"
Reg.exe Query "HKU\S-1-5-20" >nul 2>nul||echo,请用管理员权限运行&&pause&&goto:eof&&rem 是否需要管理员权限我也没测试主要进行优化

call:Hex
call:Netsh_SSID

pause
goto:eof
:Netsh_SSID
echo,获取当前所有非隐藏的无线网络SSID,注:[SSID中文和HEX]没有的16进制表会出错,[开放网络也会出错]
for /f "skip=3 tokens=1,* delims=:" %%a in ('Netsh.exe Wlan Show NetWorks')do for /f "tokens=1,* delims= " %%c in ("%%a")do if /i "%%c"=="SSID" for /f "tokens=1,* delims= " %%e in ("%%b")do call:SSID_Hex "%%e%%f"
goto:eof
:SSID_Hex
set "SSID_Hex="&set "Hex_Tmp=%~1"
for /l %%n in (0,1,100)do if not "!Hex_Tmp:~%%n,1!"=="" for /f "tokens=1,* delims==" %%i in ('set HexData_')do if "%%j"=="!Hex_Tmp:~%%n,1!" for /f "tokens=1,* delims=_" %%x in ("%%i")do if defined SSID_Hex (set "SSID_Hex=!SSID_Hex!%%y")else (set "SSID_Hex=%%y")
echo,%~1
!SSID_Hex!
call:Wifi_Add "%~1" "!SSID_Hex!"
goto:eof
:Wifi_Add
>"%temp%\%~1.xml" call:Wifi_XML "%~1" "%~2"
Netsh.exe Wlan Add Profile FileName="%temp%\%~1.xml" user=current
del/q "%temp%\%~1.xml"
set "Key="&set/p "Key=输入该网络的密码:不输入默认密码为 {%~1}
if not defined Key set "Key=%~1"
if "%Key:~7,1%"=="" echo,&echo,无线密码少于8位重新导入&goto:Wifi_Add
Netsh.exe Wlan Set ProfileParameter Name="%~1" SSIDName="%~1" ConnectionType=ESS AutoSwitch=no nonBroadcast=no Authentication=WPA2PSK Encryption=AES KeyType=passphrase keyMaterial="%Key%"
goto:eof
:Wifi_XML
echo,^<?xml version="1.0"?^>
echo,^<WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1"^>
echo, ^<name^>%~1^</name^>
echo, ^<SSIDConfig^>
echo, ^<SSID^>
echo, ^<hex^>%~2^</hex^>
echo, ^<name^>%~1^</name^>
echo, ^</SSID^>
echo, ^<nonBroadcast^>false^</nonBroadcast^>
echo, ^</SSIDConfig^>
echo, ^<connectionType^>ESS^</connectionType^>
echo, ^<connectionMode^>auto^</connectionMode^>
echo, ^<autoSwitch^>false^</autoSwitch^>
echo, ^<MSM^>
echo, ^<security^>
echo, ^<authEncryption^>
echo, ^<authentication^>open^</authentication^>
echo, ^<encryption^>none^</encryption^>
echo, ^<useOneX^>false^</useOneX^>
echo, ^</authEncryption^>
echo, ^</security^>
echo, ^</MSM^>
echo,^</WLANProfile^>
goto:eof
:Hex

set "HexData_20= "

set "HexData_2D=-"

set "HexData_30=0"

set "HexData_31=1"

set "HexData_32=2"

set "HexData_33=3"

set "HexData_34=4"

set "HexData_35=5"

set "HexData_36=6"

set "HexData_37=7"

set "HexData_38=8"

set "HexData_39=9"

set "HexData_5B=["

set "HexData_5D=]"

set "HexData_5F=_"

set "HexData_41=A"

set "HexData_42=B"

set "HexData_43=C"

set "HexData_44=D"

set "HexData_45=E"

set "HexData_46=F"

set "HexData_47=G"

set "HexData_48=H"

set "HexData_49=I"

set "HexData_4A=J"

set "HexData_4B=K"

set "HexData_4C=L"

set "HexData_4D=M"

set "HexData_4E=N"

set "HexData_4F=O"

set "HexData_50=P"

set "HexData_51=Q"

set "HexData_52=R"

set "HexData_53=S"

set "HexData_54=T"

set "HexData_55=U"

set "HexData_56=V"

set "HexData_57=W"

set "HexData_58=X"

set "HexData_59=Y"

set "HexData_5A=Z"

set "HexData_61=a"

set "HexData_62=b"

set "HexData_63=c"

set "HexData_64=d"

set "HexData_65=e"

set "HexData_66=f"

set "HexData_67=g"

set "HexData_68=h"

set "HexData_69=i"

set "HexData_6A=j"

set "HexData_6B=k"

set "HexData_6C=l"

set "HexData_6D=m"

set "HexData_6E=n"

set "HexData_6F=o"

set "HexData_70=p"

set "HexData_71=q"

set "HexData_72=r"

set "HexData_73=s"

set "HexData_74=t"

set "HexData_75=u"

set "HexData_76=v"

set "HexData_77=w"

set "HexData_78=x"

set "HexData_79=y"

set "HexData_7A=z"
goto:eof
2

评分人数

这么好的论坛你上哪找,运行测试环境为6.1.7601-64
注:请遵守互联网信息安全,勿用于非法用途

返回列表