本帖最后由 wh1234567 于 2021-2-21 01:06 编辑
- @echo off & title 一键开关网络【自动判断当前状态是否禁用或启用并进行反向切换】
- %1 echo 正在请求管理员权限。。。&&mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exit
- set WLAN=无线网络连接
- set WLAN2=本地连接
- set WLAN3=无线网络连接 2
-
- netsh interface show interface "%WLAN%" | find "已禁用" >nul 2>nul && (
- netsh interface set interface "%WLAN%" enable >nul 2>nul && (
- echo %WLAN% 已启用
- ) || (
- echo %WLAN% 启用失败
- )
- ) || (
- netsh interface set interface "%WLAN%" disabled >nul 2>nul && (
- echo %WLAN% 已禁用
- ) || (
- echo %WLAN% 禁用失败
- )
- )
-
- netsh interface show interface "%WLAN2%" | find "已禁用" >nul 2>nul && (
- netsh interface set interface "%WLAN2%" enable >nul 2>nul && (
- echo %WLAN2% 已启用
- ) || (
- echo %WLAN2% 启用失败
- )
- ) || (
- netsh interface set interface "%WLAN2%" disabled >nul 2>nul && (
- echo %WLAN2% 已禁用
- ) || (
- echo %WLAN2% 禁用失败
- )
- )
-
- netsh interface show interface "%WLAN3%" | find "已禁用" >nul 2>nul && (
- netsh interface set interface "%WLAN3%" enable >nul 2>nul && (
- echo %WLAN3% 已启用
- ) || (
- echo %WLAN3% 启用失败
- )
- ) || (
- netsh interface set interface "%WLAN3%" disabled >nul 2>nul && (
- echo %WLAN3% 已禁用
- ) || (
- echo %WLAN3% 禁用失败
- )
- )
-
- echo,&echo 请按任意键退出。
- pause>nul
复制代码 我用笨办法这样分开弄的,如何把多个:WLAN、WLAN2、WLAN3 变量合并到一起进行一次性处理?也就是一次性全部关闭与打开。希望老师帮助完美修正一下吧 |