'/*=========================================================================
' * Intro on the Internet to find a lap, are not good, there is a relatively good, the Chinese when the author added a file of their own, this file than the program itself is still big, feel bad, so I have the VBS version of the MAC modified Code was born, In the course of use if there is no Internet access to the situation to return to the network card driver (some machines are more special), if you want to return to the previous Mac can: Start--> Control Panel--> Network connection--> Click on your network card (generally "local connection")--> Click on the general properties--> configuration. --> Advanced--> Select-->networkaddress--> Right Select "does not exist"
' * FileName changemac.vbs
' * Author yongfa365
' * Version v3.0
' * WEB http://www.yongfa365.com
' * Email yongfa365[at]qq.com
' * Madetime 2007-12-09 22:17:58
' * lastmodify 2007-12-13 18:35:58
' *==========================================================================*/
On Error Resume Next
StrComputer = "."
Set objWMIService = GetObject ("winmgmts:\\" & StrComputer & "\root\cimv2")
Set colitems = objWMIService.ExecQuery ("select * from Win32_NetworkAdapterConfiguration where ipenabled=true", 48)
For each objitem in colitems
msg = MSG & "No.:" & Objitem.index & "MAC:" & objitem.macaddress & VbCrLf & "Nic:" & Objitem. Description & VbCrLf & VbCrLf
Next
IDX = InputBox (msg, "1/2 Please enter the number of the Mac you want to modify", "1")
If not IsNumeric (idx) Or Len (idx) = 0 Then
WScript.Echo "Number entered incorrectly, exit"
Wscript.Quit
End If
Mac = InputBox ("Enter the value of the MAC address you specified (note that there should be 12 consecutive digits or letters, no--,: etc.)", "2/2 Please enter the modified MAC address", "000000000000"
MAC = replace (replace (MAC, ":", ""), "-", ""), "", "" "
If regexptest ("[^\da-fa-f]", Mac) >0 Or Len (MAC) <>12 Then
WScript.Echo "Mac input is wrong, exit"
Wscript.Quit
End If
IDX = right ("00000" &idx, 4)
reg = "hklm\system\currentcontrolset\control\class\{4d36e972-e325-11ce-bfc1-08002be10318}\" & IDX
Set WshShell = CreateObject ("Wscript.Shell")
WshShell.RegWrite Reg & "\networkaddress", MAC, "REG_SZ"
WshShell.RegWrite Reg & "\ndi\params\networkaddress\default", MAC, "REG_SZ"
WshShell.RegWrite Reg & "\ndi\params\networkaddress\paramdesc", "networkaddress", "REG_SZ"
WshShell.RegWrite Reg & "\ndi\params\networkaddress\optional", "1", "REG_SZ"
' Get the name of the network card, such as "Local Connection 2"
NetworkName = WshShell.RegRead ("hklm\system\controlset001\control\network\{4d36e972-e325-11ce-bfc1-08002be10318}" \ "& WshShell.RegRead (Reg &" \netcfginstanceid ") &" \connection\name ")
Restartnetwork NetworkName
' WScript.Echo ' modified successfully
Function Restartnetwork (Sconnectionname)
' Reboot network card
' Sconnectionname = ' Local connection 5 ' can be changed to the name of the connection that needs to be controlled, such as "Wireless network Connection"
' Navigate to a network connection
Set Shellapp = CreateObject ("Shell.Application")
Set Ocontrolpanel = shellapp.namespace (3)
For each folderitem in Ocontrolpanel.items
If FolderItem. Name = "Network Connection" Then
Set onetconnections = FolderItem. GetFolder
Exit for
End If
Next
' Navigate to the network card to be processed
For each folderitem in Onetconnections.items
If LCase (FolderItem. Name) = LCase (sconnectionname) Then
Set olanconnection = FolderItem
Exit for
End If
Next
' Reboot network card
For i = 1 to 2
For each verb in olanconnection.verbs
If regexptest ("enable | disable | stop", verb.) Name) >0 Then
Verb. DoIt
Exit for
End If
Next
' Sometimes the NIC will not be able to respond to a half-day, you can set this parameter of the general program can be normal operation, or you run several more programs
Wscript.Sleep 5000
Next
End Function
' The regular test has no matching content
Function regexptest (PATRN, STRNG)
Set re = New RegExp
Re. Pattern = Patrn
Re. IgnoreCase = True
Re. Global = True
Set matches = Re. Execute (STRNG)
Regexptest = Matches.count
End Function
Current 1/2 page
12 Next read the full text