Code:
Dim strKeyPath : strKeyPath = "SYSTEM\CurrentControlSet\Control\Network"
Dim objShell : Set objShell = CreateObject("Wscript.Shell")
Const HKEY_LOCAL_MACHINE = &H80000002
Dim strMacAddress
Dim strNetWorkConnection
strNetWorkConnectionNEW = "Your New Name"
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery ("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
For Each Item In colItems
If Not IsNull(Item.MACAddress) Then strMacAddress = Item.MACAddress
Next
Dim objRegistry : Set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
objRegistry.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubkeys
For Each objSubkey In arrSubkeys
If InStr(objSubkey,"{") Then
objRegistry.EnumKey HKEY_LOCAL_MACHINE, strKeyPath &"\" &objSubkey, arrSubkeys2
For Each objSubkey2 In arrSubkeys2
If InStr(objSubkey2,"{") Then
objRegistry.EnumKey HKEY_LOCAL_MACHINE, strKeyPath &"\" &objSubkey &"\" &objSubkey2, arrSubkeys3
For Each objSubkey3 In arrSubkeys3
If Instr(objSubkey3,"Connection") Then
objRegistry.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath &"\" &objSubkey &"\" &objSubkey2 &"\" &objSubkey3,"Name",strNetworkName
objRegistry.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath &"\" &objSubkey &"\" &objSubkey2 &"\" &objSubkey3,"PnpInstanceID",strPNPInstance
If Not IsNull(strNetworkName) Then
If Not IsNull(strPNPInstance) Then
Set colItems = objWMIService.ExecQuery ("SELECT * FROM Win32_NetworkAdapter Where MACAddress = " &"'" &strMacAddress &"'")
For Each objItem In colItems
If strPNPInstance = objItem.PNPDeviceID Then strNetWorkConnection = strNetworkName
Next
End If
End If
End If
Next
End If
Next
End If
Next
objShell.Run "netsh interface set interface " &Chr(34) &strNetWorkConnection &Chr(34) &" DISABLE",0,True
objShell.Run "netsh interface set interface name = " &Chr(34) &strNetWorkConnection &Chr(34) &" newname = " &Chr(34) &strNetWorkConnectionNEW &Chr(34),0,True
WScript.Echo "Script Finished"
Bookmarks