问下有没有启用/禁用网卡的脚本?

jiecy 2011-10-14 10:27:36
网上看到有这个的VBS文件,但有的电脑提示没有找到网络文件夹什么的,不能用。有的能用,但是不知道现在的状态。请高手帮下忙,改一下或者做一个来用。
Const ssfCONTROLS = 3

sConnectionName = "本地连接" '可改成需要控制的连接名称,如"无线网络连接"等

sEnableVerb = "启用(&A)"
sDisableVerb = "停用(&B)" 'XP系统中应为 "停用(&B)"

set shellApp = createobject("shell.application")
set oControlPanel = shellApp.Namespace(ssfCONTROLS)

set oNetConnections = nothing
for each folderitem in oControlPanel.items
if folderitem.name = "网络连接" then
set oNetConnections = folderitem.getfolder: exit for
end if
next

if oNetConnections is nothing then
msgbox "未找到网络连接文件夹"
wscript.quit
end if

set oLanConnection = nothing
for each folderitem in oNetConnections.items
if lcase(folderitem.name) = lcase(sConnectionName) then
set oLanConnection = folderitem: exit for
end if
next

if oLanConnection is nothing then
msgbox "未找到 '" & sConnectionName & "' item"
wscript.quit
end if

bEnabled = true
set oEnableVerb = nothing
set oDisableVerb = nothing
s = "Verbs: " & vbcrlf
for each verb in oLanConnection.verbs
s = s & vbcrlf & verb.name
if verb.name = sEnableVerb then
set oEnableVerb = verb
bEnabled = false
end if
if verb.name = sDisableVerb then
set oDisableVerb = verb
end if
next

'debugging displays left just in case...
'
'msgbox s ': wscript.quit
'msgbox "Enabled: " & bEnabled ': wscript.quit

'not sure why, but invokeverb always seemed to work
'for enable but not disable.
'
'saving a reference to the appropriate verb object
'and calling the DoIt method always seems to work.
'
if bEnabled then
' oLanConnection.invokeverb sDisableVerb
oDisableVerb.DoIt
else
' oLanConnection.invokeverb sEnableVerb
oEnableVerb.DoIt
end if

'adjust the sleep duration below as needed...
'
'if you let the oLanConnection go out of scope
'and be destroyed too soon, the action of the verb
'may not take...
'
wscript.sleep 500

...全文
561 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
xiaoqiang11588 2011-10-20
  • 打赏
  • 举报
回复
请问高手们,如何将一个.dll文件添加到IE浏览器加载项里面,打开加载项可以看到该DLL文件已加载,比如scrobj.dll,将他安装到IE加载项里面,用批命令可以吗?具体代码呢?请详细说明,谢谢您

QQ:1158850611
mokson 2011-10-19
  • 打赏
  • 举报
回复
看到了吗,是netsh命令。多看看它的帮助文件吧。
ljc007 2011-10-18
  • 打赏
  • 举报
回复
DevCon
http://bbs.bathome.net/thread-1731-1-1.html
jiecy 2011-10-18
  • 打赏
  • 举报
回复
不可用哦兄弟
zhwei_wen 2011-10-14
  • 打赏
  • 举报
回复
一个dos下批处理形式的。保存为扩展名为.bat即可。

:start
@echo =================================================
@echo.
@echo 1:启用本地连接
@echo.
@echo 2:禁用本地连接
@echo.
@echo 3:退出
@echo.
@echo =================================================

@set /p mychoice=请选择(1,2,3):
@if %mychoice%==1 goto 1
@if %mychoice%==2 goto 2
@if %mychoice%==3 goto exit
@cls
@echo "选择错误,请重新选择"
@echo.
@goto start

:1
@netsh interface set interface name="本地连接" admin=enabled
@echo "本地连接启用成功......"
@pause
@cls
@goto start
:2
@netsh interface set interface name="本地连接" admin=disabled
@echo "本地连接禁用成功......"
@pause
@cls
@goto start
:exit
@exit

6,868

社区成员

发帖
与我相关
我的任务
社区描述
Windows 2016/2012/2008/2003/2000/NT
社区管理员
  • Windows Server社区
  • qishine
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧