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

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

...全文
544 5 打赏 收藏 转发到动态 举报
写回复
用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
xp下用netsh禁用启用网卡 在XP系统中不支持netsh interface set interface name命令扩展,所以此命令是无法正常运行的,提取2003下的ifmon.dll文件覆盖,就可以用了。 winxp下使用: netsh interface set interface "本地连接" "disabled" 会出现 如下错误提示: 代码: C:\>netsh interface set interface "本地连接" "disabled" 有指定一个或多个关键性参数 此命令提供的语法不正确。请查看帮助以获取正确的语法信息。 用法 set interface [name = ] IfName [ [admin = ] ENABLED|DISABLED [connect = ] CONNECTED|DISCONNECTED [newname = ] NewName ] 设置接口参数。 IfName - 接口名称 admin - 接口是否被启用 (仅用于非 LAN)。 connect - 是否连接接口 (仅用于非 LAN)。 newname - 接口的新名称 (仅用于非 LAN)。 注意: - 除名称外,还必须至少指定一个选项。 - 如果 connect = CONNECTED 被指定,那么接口被自动 启用,甚至在 admin = DISABLED 选项被指定时也是如 此。 =========================== 替换XP下的ifmon.dll步骤: 但是你可以把win2003系统下 C:\\WINDOWS\\system32\\ifmon.dll文件 拷贝到winxp系统下来使用,从而实现网卡禁用启用拷贝时候需要注意:需要先把 ifmon.dll文件拷贝到 C:\\WINDOWS\\system32\\dllcache 替换掉系统文件再拷贝到 C:\\WINDOWS\\system32 替换掉系统文件,若系统会提示 文件被修改了,是否从安装盘还原,选择保持修改的文件就替换成功了。 替换后就可以正常使用netsh命令来禁用启用网卡了 =========================== 根目录附件中上有win2003的ifmon.dll文件备份 DOS下重启网卡 @ rem 关闭网卡: netsh interface set interface name="本地连接" admin=DISABLED @ rem 开启网卡: netsh interface set interface name="本地连接" admin=ENABLED 使用PPPOE协议进行宽带拨号时,若要重新拨号,不要对使用PPPOE的“宽带连接”netsh,而应该对“本地连接”netsh WN7可直接用批处理 如果还不会下载我的附件吧0分。内含有XP用win2003的ifmon.dll文件备份及所用所有批处理文件。

6,850

社区成员

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

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