Option Explicit '===> DECLARE CONSTANTS <=== Const HKEY_LOCAL_MACHINE = &H80000002 Const NETWORK_CONNECTIONS = &H31& Const ForReading = 1 '===> DECLARE VARIABLES <=== Dim strComputer, objReg, i, j, arrAllInterfaces, arrIPs, strKeyPath, objShell, objFolder, objItem, colItems, Return, objFSO, objFile, strText, strCharacter, strNewCharacter, strNetConName '===> VERIFY NIC CONFIGURTION FILE IS PRESENT <=== Set objFSO = CreateObject("Scripting.FileSystemObject") If objFSO.FileExists("C:\P2V_IP_RECONFIG.txt") Then '===> DELETE OLD REGISTRY KEY FOR PHYSICAL NIC <=== strComputer = "." strKeyPath = "SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces" Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _ & strComputer & "\root\default:StdRegProv") 'Obtain array of all interfaces. objReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrAllInterfaces For i = 0 To UBound(arrAllInterfaces) 'Obtain array of IPs for each interface. objReg.GetMultiStringValue HKEY_LOCAL_MACHINE, strKeyPath & "\" & arrAllInterfaces(i), "IPAddress", arrIPs 'Iterate the IPs of each interface looking for non-zero. 'This should pick up all Interfaces that have an IP, as all 'other interfaces report "0.0.0.0" for the "IPAddress" value entry. For j = 0 To UBound(arrIPs) If arrIPs(j) <> "0.0.0.0" Then objReg.DeleteKey HKEY_LOCAL_MACHINE, strKeyPath & "\" & arrAllInterfaces(i) 'WScript.Echo arrAllInterfaces(i) End If Next Next '===> GET NAME OF OLD NETWORK CONNECTION <=== Set objFile = objFSO.OpenTextFile("C:\P2V_IP_RECONFIG.txt", ForReading) Do Until objFile.AtEndOfStream strText = "" strCharacter = objFile.Read(1) If strCharacter = Chr(34) Then Do Until objFile.AtEndOfStream strNewCharacter = objFile.Read(1) If strNewCharacter = Chr(34) Then Exit Do End If If strNewCharacter <> "" Then strText = strText & strNewCharacter End If Loop Exit Do End If Loop objFile.Close '===> RENAME NETWORK CONNECTION <=== Set objShell = CreateObject("Shell.Application") Set objFolder = objShell.Namespace(NETWORK_CONNECTIONS) Set colItems = objFolder.Items For Each objItem in colItems For i = 1 To 10 If objItem.Name = "Local Area Connection " & i Then objItem.Name = strText End If Next Next Set objShell = Nothing '===> IMPORT NIC CONFIGURATION USING NETSH<=== Set objShell = CreateObject("WScript.Shell") Return = objShell.Run("%comspec% /c netsh exec c:\P2V_IP_RECONFIG.txt", 1, True) '===> DELETE NIC CONFIGURATION FILE <=== objFSO.DeleteFile("c:\P2V_IP_RECONFIG.txt") WScript.Echo "NIC Configuration completed." '===> Destroy objects <=== Set objShell = Nothing Set objFSO = Nothing Else '===> DUMP NIC CONFIGURATION USING NETSH *** Set objShell = CreateObject("WScript.Shell") Return = objShell.Run("%comspec% /c netsh interface ip dump>c:\P2V_IP_RECONFIG.txt", 1, True) WScript.Echo "NIC CONfiguration has been saved." End If