
yang6492921明显剽窃qiushiping2的
我自己写的,不行就追问吧
@echo off&setlocal enabledelayedexpansionset m=0
for /f "skip=3 tokens=4 delims= " %%a in ('netsh interface show interface') do (
set /a m+=1
set name!m!=%%a
)
cscript /nologo "!name!1" "!name!2" "on"
pause
复制的wscript 脚本 用了能用
======================================
Const ssfCONTROLS = 3
sConnectionName = "本地连接" '可改成需要控制的连接名称,如"无线网络连接"等
sEnableVerb = "启用(&A)"
sDisableVerb = "停用(&B)" 'XP系统中应为 "停用(&B)"
set shellApp = createobject("shellapplication")
set oControlPanel = shellAppNamespace(ssfCONTROLS)
set oNetConnections = nothing
for each folderitem in oControlPanelitems
if folderitemname = "网络连接" then
set oNetConnections = folderitemgetfolder: exit for
end if
next
if oNetConnections is nothing then
msgbox "未找到网络连接文件夹"
wscriptquit
end if
set oLanConnection = nothing
for each folderitem in oNetConnectionsitems
if lcase(folderitemname) = lcase(sConnectionName) then
set oLanConnection = folderitem: exit for
end if
next
if oLanConnection is nothing then
msgbox "未找到 '" & sConnectionName & "' item"
wscriptquit
end if
bEnabled = true
set oEnableVerb = nothing
set oDisableVerb = nothing
s = "Verbs: " & vbcrlf
for each verb in oLanConnectionverbs
s = s & vbcrlf & verbname
if verbname = sEnableVerb then
set oEnableVerb = verb
bEnabled = false
end if
if verbname = sDisableVerb then
set oDisableVerb = verb
end if
next
'debugging displays left just in case
'
'msgbox s ': wscriptquit
'msgbox "Enabled: " & bEnabled ': wscriptquit
'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
' oLanConnectioninvokeverb sDisableVerb
oDisableVerbDoIt
else
' oLanConnectioninvokeverb sEnableVerb
oEnableVerbDoIt
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
'
wscriptsleep 400
==================
可以换个想法 简单的BAT脚本命令 就可以修改Ip 只要把IP改成 0000 之类的 也就算变相的 关闭了网卡 呵呵
对不?
===========================
上面的脚本 用起来很简单
首先 建立个文本
把脚本复制到里面
其中
sEnableVerb = "启用(&A)"
sDisableVerb = "停用(&B)" 'XP系统中应为 "停用(&B)"
如果想停用的脚本 就去掉启用的命令 也就是
sEnableVerb = "启用(&A)"
这样下面的一样 这样就是启用的脚本
相反 sDisableVerb = "停用(&B)" 'XP系统中应为 "停用(&B)"
后面的一样 就是停用的脚本
保存好2个分别的脚本
然后改 后缀名为VBS 即可
或者
所有脚本不变 保存为一个文件脚本
那么 第一次应用是停止 第二次就是开启
====================
脚本没问题 能用
MAC吧 简单 批处理是强大滴
@echo off
set/p mac=请输入MAC地址(格式如:00e2d5s86d9s):
set x=0
:ag3
reg query HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\000%x%\Ndi\params /s>nul 2>nul||set /a x+=1&&goto ag3
echo 找到000%x% 开始设置
reg add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\000%x% /v NetworkAddress /t REG_SZ /d %mac% /f
start 本地连接vbs
echo 重启本地连接 按任意键确定完成!
pause>nul
start 本地连接vbs
exit
这段保存为macbat
Const ssfCONTROLS = 3
sConnectionName = "本地连接" '可改成需要控制的连接名称,如"无线网络连接"、"本地连接 2"等
sEnableVerb = "启用(&A)"
sDisableVerb = "停用(&B)"
set wmi = GetObject("winmgmts:")
set colSystem = wmiExecQuery("select from Win32_OperatingSystem")
for each objSystem in colSystem
if Instr(UCase(objSystemCaption),UCase("Windows XP")) then '如果系统是WinXP
sNetConnections = "网络连接"
sDisableVerb = "停用(&B)"
else '如果系统是Win2000
sNetConnections = "网络和拨号连接"
sDisableVerb = "禁用(&B)"
end if
next
set shellApp = createobject("shellapplication")
set oControlPanel = shellAppNamespace(ssfCONTROLS)
set oNetConnections = nothing
for each folderitem in oControlPanelitems
if folderitemname = sNetConnections then
set oNetConnections = folderitemgetfolder
exit for
end if
next
if oNetConnections is nothing then
WScriptEcho "控制面板中未找到" & sNetConnections & "文件夹"
wscriptquit
end if
set oLanConnection = nothing
for each folderitem in oNetConnectionsitems
'WScriptEcho folderitemname
if lcase(folderitemname) = lcase(sConnectionName) then
set oLanConnection = folderitem
exit for
end if
next
if oLanConnection is nothing then
WScriptEcho sNetConnections & "中未找到'" & sConnectionName & "'项目"
wscriptQuit
end if
bEnabled = true
set oEnableVerb = nothing
set oDisableVerb = nothing
s = "Verbs: " & vbcrlf
for each verb in oLanConnectionverbs
'WScriptEcho verbname
's = s & vbcrlf & verbname
if verbname = sEnableVerb then
set oEnableVerb = verb
bEnabled = false
end if
if verbname = sDisableVerb then
set oDisableVerb = verb
end if
next
'debugging displays left just in case
'
'msgbox s ': wscriptquit
'msgbox "Enabled: " & bEnabled ': wscriptquit
'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
' oLanConnectioninvokeverb sDisableVerb
'if msgbox(sConnectionName & " 当前状态:已启用", 36, "是否停用")=vbYes then
oDisableVerbDoIt
'then
else
' oLanConnectioninvokeverb sEnableVerb
'if msgbox(sConnectionName & " 当前状态:已禁用", 36, "是否启用")=vbYes then
oEnableVerbDoIt
'then
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
'
wscriptsleep 1000
set oNetConnections = nothing
set oLanConnection = nothing
set oEnableVerb = nothing
set oDisableVerb = nothing
这段保存为 本地连接vbs
如果是笔记本可能会出错 因为笔记本的mac我没考虑 你可以Q我279325850
帮你改改就可以了
多网卡也会出错 我也没考虑 这个见谅 我不会
macbat和本地连接vbs放在同一路经运行macbat就可以了
另外下面的vbs代码作用是重启本地连接(修改mac地址后必须的) 代码不是我写的 有错找我也没用 上面批处理代码的任何问题请Q我
以上就是关于bat批处理命令查找当前启用并连接的网卡名字全部的内容,包括:bat批处理命令查找当前启用并连接的网卡名字、如何用脚本实时启用、禁用网卡、如何用批处理文件实现自动修改网卡物理地址等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)