请教:请问启用网卡,禁用网卡具体是调用了哪个文件,并用了什么参数?

amwlq 2003-12-02 11:22:22
我用的是宽带,一开机就可以上网,但我不想这样,想在开机后想上网时上网,我想通过这种方法解决,关机的时候,运行关掉网卡,这样应该怎样做?
...全文
50 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
myqiao 2004-02-25
  • 打赏
  • 举报
回复
这个脚本在中文版下不能正常运行,谁有能在中文版下正常运行的?
myqiao 2004-02-25
  • 打赏
  • 举报
回复
我把上面的改了一下,现在可以了,这是对本地连接操作的,如果是其他,如本地连接2什么的,可以在下面相应位置改,
主要是启用(&A)和禁用(&B)这儿试了很长时间才试出来.
祝好运...
Const ssfCONTROLS = 3

sConnectionName = "本地连接"

sEnableVerb = "启用(&A)"
sDisableVerb = "禁用(&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 1000
amwlq 2003-12-08
  • 打赏
  • 举报
回复
XP应该装了吧,大家回到问题的点上来,怎么解决啊?
icuc88 2003-12-03
  • 打赏
  • 举报
回复
你需要安装Windows Script Host,

不过系统默认是安装了的。
code2004 2003-12-03
  • 打赏
  • 举报
回复
可以用是C#编写脚本吗?
amwlq 2003-12-03
  • 打赏
  • 举报
回复
这又关拨号的事?二层楼上的大哥,我的是XP啊,附件安装的是98吧,

叫什么scrip host的
shishikeke 2003-12-02
  • 打赏
  • 举报
回复
在附件里面有,你自己安装一下,好像叫host文件吧,
amwlq 2003-12-02
  • 打赏
  • 举报
回复
提示:"没有文件扩展为.vbs 的脚本引擎.
amwlq 2003-12-02
  • 打赏
  • 举报
回复
我的是XP
amwlq 2003-12-02
  • 打赏
  • 举报
回复
具体怎样做呢?ToggleLanConnection.vbs文件是要调用吧,
icuc88 2003-12-02
  • 打赏
  • 举报
回复
使用脚本,如下:
ToggleLanConnection.vbs
==================

Const ssfCONTROLS = 3

sConnectionName = "Local Area Connection"

sEnableVerb = "En&able"
sDisableVerb = "Disa&ble"

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

set oNetConnections = nothing
for each folderitem in oControlPanel.items
if folderitem.name = "Network and Dial-up Connections" then
set oNetConnections = folderitem.getfolder: exit for
end if
next

if oNetConnections is nothing then
msgbox "Couldn't find 'Network and Dial-up Connections' folder"
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 "Couldn't find '" & 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 1000




ghostfish 2003-12-02
  • 打赏
  • 举报
回复
你是装的什么拨号软件?是什么协议?是否设置了路由器?还是小区上网?而不是ADSL

6,849

社区成员

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

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