For some various weird reason, we have a system image that won't let us use netsh to rename the NICs.
And I found a vbscript that works, so I started to see if I could figure out how-to do it in pure AutoIT. I was stumped - but a rethink fixed me.
So I removed the original post with VBSCRIPT here and put my solution, hoping it helps someone else down the line. Of course you could make the script accept inputs as variables or what have we.
Global $OldNicName, $NewNicName ;~ Global $OldNicName = "Local Area Connection" ; placeholder ;~ Global $NewNicName = "The LAN" ; placeholder Global $NewNicName = "Local Area Connection" ; placeholder Global $OldNicName = "The LAN" ; placeholder _DoNICName() Func _DoNICName() Local $colNICItems, $objWMIService, $objItem $objWMIService = ObjGet("winmgmts:{impersonationLevel = impersonate}!" & "." & "rootcimv2") $colNICItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapter", "WQL", 0x10 + 0X20) If IsObj($colNICItems) Then For $objItem In $colNICItems If StringInStr($objItem.NetConnectionID, $OldNicName) Then RunWait(@ComSpec & " /c " & "WMIC NIC where NetConnectionID=""" & $OldNicName & """ set NetConnectionID=""" & $NewNicName & '"', @WindowsDir, @SW_HIDE) EndIf Next EndIf EndFunc ;==>_DoNICName
Edited by ModemJunki, 07 June 2012 - 07:11 PM.





