' ===----( * )----=== _ - _ --==-- _ - _ ===----( * )----=== ' ' _ - - - ~ ~ ~ .. ~ ~ ~ - - - _ _ ' ' IPConfig.vbs script by Dzmitry Stremkouski ( http://mitroko.com ) 2008 ' ' - _ _ _ _ - .--. - _ _ _ _ - - ' ' ===--( * )--=== ~ _ - /\\/\\ - _ ~ ===--( * )--=== ' ' ===--=== ===------=== . \\/\\/ . ===------=== ===--=== ' Option explicit '.\ '::' /.' ticilpxe noitpO ' - \ `` / - ' ' F R E E D O M \/ M O D E E R F ' GPLv2. ' / \ ' ===== '8 8` const HKEY_CURRENT_USER = &H80000001 const HKEY_LOCAL_MACHINE = &H80000002 const Sp = " " Dim objWMIService, colItems, objItem, netItems, objnetItem Dim oReg Dim SZ_DNSSuffix, DWORD_DHCPFlag, MSZ_IPAddress, MSZ_NetMask, MSZ_DefaultGW, SZ_DNServers Dim iC, gC Dim DNS, DelimFlagCount, DNSNum, DNSCounter, DelimPos, DNSa, DNSb Dim obArgs Set obArgs = WScript.Arguments Set objWMIService = GetObject("winmgmts:\\.\root\CIMV2") Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapter", "WQL", &h30) Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv") WScript.Echo " ------------------------------------------------------------------------------" WScript.Echo " Network Interfaces configuration " WScript.Echo " ------------------------------------------------------------------------------" For Each objItem In colItems If (Instr(1, LCASE(objItem.PNPDeviceID), LCASE("PCI\")) = 1) or (Instr(1, LCASE(objItem.PNPDeviceID), LCASE("USB\")) = 1) Then Set netItems = objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration Where Caption = """ & objItem.Caption & """ ") If obArgs.Count = 0 Then For Each objnetItem In netItems If (objItem.Caption = objnetItem.Caption) Then WScript.Echo objItem.NetConnectionID & " - Ethernet adapter:" WScript.Echo oReg.GetStringValue HKEY_LOCAL_MACHINE,"System\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\" & objnetItem.SettingID,"Domain",SZ_DNSSuffix WScript.Echo Sp & "DNS-Suffix . . . . . . . . . . . : " & SZ_DNSSuffix oReg.GetDWORDValue HKEY_LOCAL_MACHINE,"System\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\" & objnetItem.SettingID,"EnableDHCP",DWORD_DHCPFlag If DWORD_DHCPFlag = 0 Then WScript.Echo Sp & "DHCP Enabled . . . . . . . . . . : No" Else WScript.Echo Sp & "DHCP Enabled . . . . . . . . . . : Yes" End If oReg.GetMultiStringValue HKEY_LOCAL_MACHINE,"System\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\" & objnetItem.SettingID,"IPAddress",MSZ_IPAddress oReg.GetMultiStringValue HKEY_LOCAL_MACHINE,"System\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\" & objnetItem.SettingID,"SubnetMask",MSZ_NetMask oReg.GetMultiStringValue HKEY_LOCAL_MACHINE,"System\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\" & objnetItem.SettingID,"DefaultGateway",MSZ_DefaultGW For iC = 0 to UBound(MSZ_IPAddress,1) If iC < 9 Then WScript.Echo Sp & "IP-Address - " & iC + 1 & " . . . . . . . . . : " & MSZ_IPAddress(iC) & "/" & MSZ_NetMask(iC) Else WScript.Echo Sp & "IP-Address - " & iC + 1 & " . . . . . . . . . : " & MSZ_IPAddress(iC) & "/" & MSZ_NetMask(iC) End If Next oReg.GetStringValue HKEY_LOCAL_MACHINE,"System\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\" & objnetItem.SettingID,"NameServer",SZ_DNServers DNS = SZ_DNServers DelimFlagCount = InStr(1, DNS, ",") DNSNum = 0 For DNSCounter = 1 to DelimFlagCount + 1 DelimPos = InStr(1, DNS, ",") If DelimPos > 0 Then DNSa = Mid(DNS, 1, DelimPos - 1) DNSb = Mid(DNS, DelimPos + 1, Len(DNS)) DNS = DNSb DNSNum = DNSNum + 1 WScript.Echo Sp & "DNS - " & DNSNum & " . . . . . . . . . . . . . : " & DNSa End If Next WScript.Echo Sp & "DNS - " & DNSNum + 1 & " . . . . . . . . . . . . . : " & DNS WScript.Echo Sp & "Gateways:" For gC = 0 to UBound(MSZ_DefaultGW,1) If gC < 9 Then WScript.Echo Sp & "Gateway - " & gC + 1 & " . . . . . . . . . . . : " & MSZ_DefaultGW(gC) Else WScript.Echo Sp & "Gateway - " & gC + 1 & " . . . . . . . . . . : " & MSZ_DefaultGW(gC) End If Next WScript.Echo End If Next Else If objItem.NetConnectionID = obArgs.Item(0) Then For Each objnetItem In netItems WScript.Echo objItem.NetConnectionID & " - Ethernet adapter:" WScript.Echo oReg.GetStringValue HKEY_LOCAL_MACHINE,"System\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\" & objnetItem.SettingID,"Domain",SZ_DNSSuffix WScript.Echo Sp & "DNS-Suffix . . . . . . . . . . . : " & SZ_DNSSuffix oReg.GetDWORDValue HKEY_LOCAL_MACHINE,"System\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\" & objnetItem.SettingID,"EnableDHCP",DWORD_DHCPFlag If DWORD_DHCPFlag = 0 Then WScript.Echo Sp & "DHCP Enabled . . . . . . . . . . : No" Else WScript.Echo Sp & "DHCP Enabled . . . . . . . . . . : Yes" End If oReg.GetMultiStringValue HKEY_LOCAL_MACHINE,"System\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\" & objnetItem.SettingID,"IPAddress",MSZ_IPAddress oReg.GetMultiStringValue HKEY_LOCAL_MACHINE,"System\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\" & objnetItem.SettingID,"SubnetMask",MSZ_NetMask oReg.GetMultiStringValue HKEY_LOCAL_MACHINE,"System\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\" & objnetItem.SettingID,"DefaultGateway",MSZ_DefaultGW For iC = 0 to UBound(MSZ_IPAddress,1) If iC < 9 Then WScript.Echo Sp & "IP-Address - " & iC + 1 & " . . . . . . . . . : " & MSZ_IPAddress(iC) & "/" & MSZ_NetMask(iC) Else WScript.Echo Sp & "IP-Address - " & iC + 1 & " . . . . . . . . . : " & MSZ_IPAddress(iC) & "/" & MSZ_NetMask(iC) End If Next oReg.GetStringValue HKEY_LOCAL_MACHINE,"System\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\" & objnetItem.SettingID,"NameServer",SZ_DNServers DNS = SZ_DNServers DelimFlagCount = InStr(1, DNS, ",") DNSNum = 0 For DNSCounter = 1 to DelimFlagCount + 1 DelimPos = InStr(1, DNS, ",") If DelimPos > 0 Then DNSa = Mid(DNS, 1, DelimPos - 1) DNSb = Mid(DNS, DelimPos + 1, Len(DNS)) DNS = DNSb DNSNum = DNSNum + 1 WScript.Echo Sp & "DNS - " & DNSNum & " . . . . . . . . . . . . . : " & DNSa End If Next WScript.Echo Sp & "DNS - " & DNSNum + 1 & " . . . . . . . . . . . . . : " & DNS WScript.Echo Sp & "Gateways:" For gC = 0 to UBound(MSZ_DefaultGW,1) If gC < 9 Then WScript.Echo Sp & "Gateway - " & gC + 1 & " . . . . . . . . . . . : " & MSZ_DefaultGW(gC) Else WScript.Echo Sp & "Gateway - " & gC + 1 & " . . . . . . . . . . : " & MSZ_DefaultGW(gC) End If Next WScript.Echo Next End If End If Set netItems = Nothing End If Next Set oReg = Nothing Set colItems = Nothing Set objWMIService = Nothing