'/*=========================================================================
'*Intro网上找了一圈,都不怎么好,有一个比较不错的,汉化作者汉化时加了个自己的介绍文件,这个文件比程序本身还大,感觉不爽,于是本人的VBS版MAC修改代码便诞生了,在使用过程中如果出现不能上网的情况得返回一下网卡驱动(有些机器比较特别),如果要返回以前的MAC可以:开始-->控制面板-->网络连接-->点击您的网卡(一般是"本地连接")-->点击常规里的属性-->配置..-->高级-->选中-->NetworkAddress-->右边选择"不存在"
'*FileNameChangeMAC.vbs
'*Authoryongfa365
'*Versionv3.0
'*WEBhttp://www.yongfa365.com
'*Emailyongfa365[at]qq.com
'*MadeTime2007-12-0922:17:58
'*LastModify2007-12-1318:35:58
'*==========================================================================*/
OnErrorResumeNext
strComputer="."
SetobjWMIService=GetObject("winmgmts:"&strComputer&"rootcimv2")
SetcolItems=objWMIService.ExecQuery("Select*fromWin32_NetworkAdapterConfigurationwhereIPEnabled=true",,48)
ForEachobjItemincolItems
msg=msg&"编号:"&objItem.Index&"MAC:"&objItem.MACAddress&vbCrLf&"网卡:"&objItem.Description&vbCrLf&vbCrLf
Next
idx=InputBox(msg,"1/2请输入您要修改的MAC的编号","1")
IfNotIsNumeric(idx)OrLen(idx)=0Then
WScript.Echo"编号输入有误,退出"
Wscript.Quit
EndIf
MAC=InputBox("输入你指定的MAC地址值(注意应该是12位的连续数字或字母,其间没有-、:等分隔符)","2/2请输入修改后的MAC地址","000000000000")
MAC=Replace(Replace(Replace(MAC,":",""),"-",""),"","")
IfRegExpTest("[^da-fA-F]",MAC)>0OrLen(MAC)<>12Then
WScript.Echo"MAC输入有误,退出"
Wscript.Quit
EndIf
idx=Right("00000"&idx,4)
reg="HKLMSYSTEMCurrentControlSetControlClass{4D36E972-E325-11CE-BFC1-08002bE10318}"&idx
SetWSHShell=CreateObject("WScript.Shell")
WshShell.RegWritereg&"NetworkAddress",MAC,"REG_SZ"
WshShell.RegWritereg&"NdiparamsNetworkAddressdefault",MAC,"REG_SZ"
WshShell.RegWritereg&"NdiparamsNetworkAddressParamDesc","NetworkAddress","REG_SZ"
WshShell.RegWritereg&"NdiparamsNetworkAddressoptional","1","REG_SZ"
'得到网卡的名称,比如“本地连接2”
NetWorkName=WshShell.RegRead("HKLMSYSTEMControlSet001ControlNetwork{4D36E972-E325-11CE-BFC1-08002BE10318}"&WshShell.RegRead(reg&"NetCfgInstanceId")&"ConnectionName")
restartNetWorkNetWorkName
'WScript.Echo"修改成功"
FunctionrestartNetWork(sConnectionName)
'重启网卡
'sConnectionName="本地连接5"'可改成需要控制的连接名称,如"无线网络连接"等
'定位到网络连接
SetshellApp=CreateObject("shell.application")
SetoControlPanel=shellApp.Namespace(3)
ForEachfolderiteminoControlPanel.Items
Iffolderitem.Name="网络连接"Then
SetoNetConnections=folderitem.GetFolder
ExitFor
EndIf
Next
'定位到要处理的网卡
ForEachfolderiteminoNetConnections.Items
IfLCase(folderitem.Name)=LCase(sConnectionName)Then
SetoLanConnection=folderitem
ExitFor
EndIf
Next
'重启网卡
Fori=1To2
ForEachverbinoLanConnection.verbs
IfRegExpTest("启用|禁用|停止",verb.Name)>0Then
verb.DoIt
ExitFor
EndIf
Next
'有时网卡半天反应不过来,可以把这个参数设的大点一般程序可以正常运行,或您多运行几次程序
WScript.Sleep5000
Next
EndFunction
'正则测试有没有匹配内容
FunctionRegExpTest(patrn,strng)
Setre=NewRegExp
re.Pattern=patrn
re.IgnoreCase=True
re.Global=True
SetMatches=re.Execute(strng)
RegExpTest=Matches.Count
EndFunction
当前1/2页12下一页阅读全文