[Python]
import os
def interface_info():
for i in os.popen('netsh interface show interface'):
if i := i.strip():
ls = i.split()
return ls[-1], ls[-3]
print(interface_info())
i_name, i_state = interface_info()
if i_state == '已连接':
os.popen(f'netsh interface set interface {i_name} disable')
print('连接已断开')
else:
os.popen(f'netsh interface set interface {i_name} enable')
print('连接已恢复')
BAT版,功能与上面的一致
@echo off
for /f "tokens=2,4" %%i in ('netsh interface show interface') do (
set state=%%i
set name=%%j
)
echo 当前:%name% %state%
if %state%==已连接 (
netsh interface set interface %name% disable
echo 连接已断开
) else (
netsh interface set interface %name% enable
echo 连接已恢复
)
pause

li642041156
- 粉丝: 5
最新资源
- 改善交流伺服系统脉冲接口抗干扰能力(00001).doc
- 单片机和USB接口技术高速数据采集系统设计方案.doc
- GeekDesk-C#资源
- 大数据下互联网广告精准投放策略探讨.docx
- 浅议中职院校计算机课程实施翻转课堂的保障条件.docx
- 大数据产业新高地成就贵安精彩.docx
- gis中属性数据的输入和管理.ppt
- 数字图像处理降噪滤波大作业.doc
- 大数据、信息化时代电子档案管理的安全问题研究.docx
- watermark-js-plus-JavaScript资源
- (源码)基于Hyperf框架和Vue的微信服务系统.zip
- 电力信息化管理中存在的问题及对策解析.docx
- 网络环境下企业会计信息披露研究.docx
- 人工智能从前沿概念走进青少年实际生活.docx
- 计算机多媒体技术的应用现状及其发展前景分析.docx
- 农业电子商务平台建设现状附存在问题.doc
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈


