@echo off ::author tobios rem 请修改config中的信息 rem ConfigStart set "device=1" ::奇数为手机端,偶数为pc端口 set "operator=cmcc" ::移动为cmcc,电信为telecom,联通为unicom set "user_account=这里替换成用户名" set "user_password=这里替换成密码" rem ConfigEnd
:GetIP for /f "tokens=2 delims=:(" %%iin ('ipconfig /all ^|findstr "IPv4" ^|findstr "10."') do ( set "IP=%%i" goto :ShowIP )
:Login for /f %%iin ('curl -s "http://192.168.200.2:801/eportal/?c=Portal&a=login&callback=dr1003&login_method=1&user_account=%%2C%device%%%2C%user_account%%%40%operator%&user_password=%user_password%&wlan_user_ip=%ip%&wlan_user_ipv6=&wlan_user_mac=000000000000&wlan_ac_ip=&wlan_ac_name=&jsVersion=3.3.3&v=9863"') do ( set "flag=%%i" goto :ShowResult )
:ShowResult set "flag_ok=dr1003({"result":"1","msg":"\u8ba4\u8bc1\u6210\u529f"})" set "flag_reget=dr1003({"result":"0","msg":"","ret_code":2})" set "flag_error=dr1003({"result":"0","msg":"bGRhcCBhdXRoIGVycm9y","ret_code":1})" if "%flag%"=="%flag_ok%" ( echo 认证成功 goto :Exit ) elseif "%flag%"=="%flag_error%" ( echo 认证失败 goto :Exit ) elseif "%flag%"=="%flag_reget%" ( echo 已连接,请勿重复操作 goto :Exit ) echo%flag%
:Exit pause
接下来实现连接WiFi自动运行脚本
打开任务计划程序
点击右侧‘创建任务’,名称、描述按自己喜好写
点击触发器选项并点击新建
选择开始任务为发生事件时,并选择自定义、点击新建事件筛选器
点击xml并勾选手动编辑查询,替换为以下内容,后点确定
1 2 3 4 5
<QueryList> <QueryId="0"Path="Microsoft-Windows-WLAN-AutoConfig/Operational"> <SelectPath="Microsoft-Windows-WLAN-AutoConfig/Operational">*[System[(EventID=8001)]][EventData[Data[@Name='SSID']='CQUPT'] or EventData[Data[@Name='SSID']='CQUPT-2.4G'] or EventData[Data[@Name='SSID']='CQUPT-5G']]</Select> </Query> </QueryList>