资源描述
用批处理禁用或者启动网卡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
展开阅读全文