求一禁用其网络连接.bat
公司需每天7:30运行一程序,主机有两张网卡,其一ip地址为:192.100.110.X另一张ip地址为:192.168.0.X程序每次运行需占用ip为192.100.1...
公司需每天7:30运行一程序,主机有两张网卡,其一ip地址为:192.100.110.X 另一张ip地址为:192.168.0.X
程序每次运行需占用ip为192.100.110.X 网段, 但程序总会自动占用192.168.0.X网段,导致程序无法运行.
我的意思就是用一bat在每天7:30时把其中一网卡暂时禁用,然后程序运行,待运行完毕后,再启用192.100.110.X 网段.
先谢谢大家了 展开
程序每次运行需占用ip为192.100.110.X 网段, 但程序总会自动占用192.168.0.X网段,导致程序无法运行.
我的意思就是用一bat在每天7:30时把其中一网卡暂时禁用,然后程序运行,待运行完毕后,再启用192.100.110.X 网段.
先谢谢大家了 展开
1个回答
展开全部
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 400
文本文档保存为 vbs 双击VBS 为禁用
双击VBS 为启用
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 400
文本文档保存为 vbs 双击VBS 为禁用
双击VBS 为启用
力控科技
2024-11-28 广告
2024-11-28 广告
第一步:看XPE是什么版,如果内核是英文版,需要安装一个MUI包,即语言包。第二步:进入控制面板-区域和语言选项,如下图,在区域选项中,选择“中文(中国)”,位置也为“中国”,在高级选项中,代码页转换表中,将所有的“简体中文”都选择上。...
点击进入详情页
本回答由力控科技提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询