用批处理禁用或者启动网卡

上传人:小** 文档编号:64337303 上传时间:2022-03-21 格式:DOC 页数:3 大小:55KB
返回 下载 相关 举报
用批处理禁用或者启动网卡_第1页
第1页 / 共3页
用批处理禁用或者启动网卡_第2页
第2页 / 共3页
用批处理禁用或者启动网卡_第3页
第3页 / 共3页
亲,该文档总共3页,全部预览完了,如果喜欢就下载吧!
资源描述
用批处理禁用或者启动网卡CODE1:平台: WINDOWS 2K/XP HOME/PRO适用环境:目录共享或打印机共享,经常因达到 10 人的连接上限,而不能给他人正常提供 文件和打印共享服务解决方法:1、PRO 版系统,修改组策略secpol.msc/ 本地策略 /安全选项 /在挂起会话之前所需时间,改为 1 分钟2、用批处理,然后设计划任务“net session /delete /y”3、使用如下脚本,每隔30秒(或自定义间隔时间)清除访问连接,保存为bat格式echo offrem 定义循环间隔时间:set secs=30echo.echo =echo此脚本用于计算机共享访问达到上限后使用echo运行脚本后会自动断开一些访问连接echo每secs%秒种进行查询,并执行清除命令echo =echo.net session nul | goto :error:beginset clear=0 echo.for /f toke ns=1,2 %i in (net session A| find ) do (net session %i /delete /y nul 2&1set clear=1echo %time:0,8% 清除访问来源 : %i %j)echo.if %clear%=0 (echo %time:0,8%现无人访问此计算机,%secs%秒后继续 )else (echo %time:0,8% 清除完毕,%secs%秒后继续 )ping 127.0.0.1 -n %secs% -w 0 nul 2&1goto begin:errorecho 权限不足,无法执行,请与管理员联系 .echo.pause nul 2&1 |echo 请按任意键关闭 .CODE2: echo offrem 适用于 Win2003rem 把 Win2003 的 ifmon.dll 拷贝到 WinXP 以后 WinXP 也可以用 rem 禁用本地连接netsh interface set interface name= 本地连接 admin=DISABLED rem 启用本地连接netsh interface set interface name= 本地连接 admin=ENABLEDCODE3:echo offrem 用批处理调用 devcon.exe 来实现echo 请输入你的选择: (禁用网卡为 N, 启用为 Y)set/p SELECT=if /i %SELECT%=Y set SELECT=ENABLE&GOTO :DOif /i %SELECT%=N set SELECT=DISABLEdo:DOfor /f tokens=2 delims=& %i in (devcon find pci* A| findstr Fast Ethernet) devcon %SELECT% *%i*NULdevcon.exehttp:/rtngslin.moe.hm/cndos-up/img/496.zipCODE4:XP 下可以用 VBS 来实现Const ssfCONTROLS = 3sConnectionName = 本地连接 可改成需要控制的连接名称,如无线网络连接 等sEnableVerb =启用(&A)sDisableVerb =停用(&B) 非xp系统可能 是禁用set shellApp = createobject(shell.application)set oControlPanel = shellApp.Namespace(ssfCONTROLS) set oNetConnections = nothingfor each folderitem in oControlPanel.itemsif folderitem.name = 网络连接 thenset oNetConnections = folderitem.getfolder: exit for end if nextif oNetConnections is nothing then msgbox 未找到网络连接文件夹 wscript.quit end ifset oLanConnection = nothingfor each folderitem in oNetConnections.itemsif lcase(folderitem.name) = lcase(sConnectionName) then set oLanConnection = folderitem: exit forend ifnextif oLanConnection is nothing thenmsgbox 未找到 & sConnectionName & item wscript.quit end ifbEnabled = trueset oEnableVerb = nothingset oDisableVerb = nothings = Verbs: & vbcrlffor each verb in oLanConnection.verbss = s & vbcrlf & verb.nameif verb.name = sEnableV erb thenset oEnableVerb = verb bEnabled = false end ifif verb.name = sDisableV erb thenset oDisableVerb = verb end if nextdebugging displays left just in case.Imsgbox s : wscript.quitmsgbox Enabled: & bEnabled : wscript.quitnot sure why, but invokeverb always seemed to workfor enable but not disable.Isaving a reference to the appropriate verb object and calling the DoIt method always seems to work.if bEnabled then oLanConnection.invokeverb sDisableV erb oDisableV erb.DoItelse oLanConnection.invokeverb sEnableV erb oEnableVerb.DoItend ifadjust the sleep duration below as needed.Iif you let the oLanConnection go out of scope and be destroyed too soon, the action of the verb may not take.Iwscript.sleep 400
展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 办公文档 > 解决方案


copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!