【批处理】网卡断开wifi后自动连接

时间: 2023-09-15 15:20:25 浏览: 73
可以使用以下批处理代码实现网卡断开wifi后自动连接: @echo off setlocal EnableDelayedExpansion set "ssid=your_wifi_ssid" set "password=your_wifi_password" set "profile=%TEMP%\wifi_profile.xml" echo ^<?xml version="1.0" encoding="US-ASCII"?^> > "!profile!" echo ^<WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1"^> >> "!profile!" echo ^<name^>!ssid!^</name^> >> "!profile!" echo ^<SSIDConfig^> >> "!profile!" echo ^<SSID^> >> "!profile!" echo ^<name^>!ssid!^</name^> >> "!profile!" echo ^</SSID^> >> "!profile!" echo ^</SSIDConfig^> >> "!profile!" echo ^<connectionType^>ESS^</connectionType^> >> "!profile!" echo ^<connectionMode^>manual^</connectionMode^> >> "!profile!" echo ^<MSM^> >> "!profile!" echo ^<security^> >> "!profile!" echo ^<authEncryption^> >> "!profile!" echo ^<authentication^>WPA2PSK^</authentication^> >> "!profile!" echo ^<encryption^>AES^</encryption^> >> "!profile!" echo ^<useOneX^>false^</useOneX^> >> "!profile!" echo ^</authEncryption^> >> "!profile!" echo ^<sharedKey^> >> "!profile!" echo ^<keyType^>passPhrase^</keyType^> >> "!profile!" echo ^<protected^>false^</protected^> >> "!profile!" echo ^<keyMaterial^>!password!^</keyMaterial^> >> "!profile!" echo ^</sharedKey^> >> "!profile!" echo ^</security^> >> "!profile!" echo ^</MSM^> >> "!profile!" echo ^</WLANProfile^> >> "!profile!" netsh wlan add profile filename="!profile!" user=current :retry netsh wlan connect name="!ssid!" >nul ping -n 5 127.0.0.1 >nul set "connected=false" for /f "tokens=2 delims=:" %%a in ('netsh wlan show interface ^| findstr /c:"State"') do ( set "state=%%a" if "!state:~1!"=="not" ( set "connected=false" ) else ( set "connected=true" ) ) if not "!connected!"=="true" goto retry echo Connected to !ssid! pause exit 将代码中的“your_wifi_ssid”和“your_wifi_password”替换为你的WiFi SSID和密码。执行批处理后,它会创建一个WiFi配置文件,并尝试连接到指定的WiFi。如果连接失败,它会重复尝试连接,直到成功连接为止。成功连接后,它将打印“Connected to your_wifi_ssid!”并暂停脚本。

相关推荐

最新推荐

recommend-type

自动生成linux网卡配置脚本分享

主要介绍了自动生成linux网卡配置的脚本,因为Linux虚拟机在复制时候网卡信息会更新,所以导致需要重新配置网卡。本脚本功能,第一次添加网卡后,启动虚拟机,然后运行脚本(可以写在启动脚步中),然后根据ifconfig...
recommend-type

CentOS虚拟机克隆后无法上网(网卡信息不一致)问题的解决方法

主要为大家详细介绍了CentOS虚拟机克隆后无法上网,即网卡信息不一致问题的解决方法,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
recommend-type

intel82574网卡手册

intel82574的网卡手册,包含寄存器手册和操作流程,中断说明,bar空间映射等等 The 82574 family (82574L and 82574IT) are single, compact, low power components that offer a fully-integrated Gigabit Ethernet...
recommend-type

Java怎么获取多网卡本地ip

java获取本地ip,获取多网卡本地ip在项目中经常会用到,下面小编把代码分享到脚本之家平台,供大家参考
recommend-type

Centos7实现多网卡team技术

Centos7实现多网卡team技术,将多个网卡通过虚拟化team技术进行绑定,提高网络通信的可靠性,多用于金融互联网行业
recommend-type

zigbee-cluster-library-specification

最新的zigbee-cluster-library-specification说明文档。
recommend-type

管理建模和仿真的文件

管理Boualem Benatallah引用此版本:布阿利姆·贝纳塔拉。管理建模和仿真。约瑟夫-傅立叶大学-格勒诺布尔第一大学,1996年。法语。NNT:电话:00345357HAL ID:电话:00345357https://theses.hal.science/tel-003453572008年12月9日提交HAL是一个多学科的开放存取档案馆,用于存放和传播科学研究论文,无论它们是否被公开。论文可以来自法国或国外的教学和研究机构,也可以来自公共或私人研究中心。L’archive ouverte pluridisciplinaire
recommend-type

MATLAB柱状图在信号处理中的应用:可视化信号特征和频谱分析

![matlab画柱状图](https://img-blog.csdnimg.cn/3f32348f1c9c4481a6f5931993732f97.png) # 1. MATLAB柱状图概述** MATLAB柱状图是一种图形化工具,用于可视化数据中不同类别或组的分布情况。它通过绘制垂直条形来表示每个类别或组中的数据值。柱状图在信号处理中广泛用于可视化信号特征和进行频谱分析。 柱状图的优点在于其简单易懂,能够直观地展示数据分布。在信号处理中,柱状图可以帮助工程师识别信号中的模式、趋势和异常情况,从而为信号分析和处理提供有价值的见解。 # 2. 柱状图在信号处理中的应用 柱状图在信号处理
recommend-type

HSV转为RGB的计算公式

HSV (Hue, Saturation, Value) 和 RGB (Red, Green, Blue) 是两种表示颜色的方式。下面是将 HSV 转换为 RGB 的计算公式: 1. 将 HSV 中的 S 和 V 值除以 100,得到范围在 0~1 之间的值。 2. 计算色相 H 在 RGB 中的值。如果 H 的范围在 0~60 或者 300~360 之间,则 R = V,G = (H/60)×V,B = 0。如果 H 的范围在 60~120 之间,则 R = ((120-H)/60)×V,G = V,B = 0。如果 H 的范围在 120~180 之间,则 R = 0,G = V,B =
recommend-type

JSBSim Reference Manual

JSBSim参考手册,其中包含JSBSim简介,JSBSim配置文件xml的编写语法,编程手册以及一些应用实例等。其中有部分内容还没有写完,估计有生之年很难看到完整版了,但是内容还是很有参考价值的。