Computer IP information
Posted: Thu Dec 15, 2005 10:59 pm
This script will gather the OS version and IP adress information including DHCP, DNS, WINS and such and display it in a browser window.
Code: Select all
sComputer = InputBox("Please enter one of the following:" & vbcrlf & vbcrlf & "ComputerName" _
& vbcrlf & "IP Address" & vbcrlf & ". (for local)","Computer Name")
If sComputer = "" Then Wscript.Quit
Set objExplorer = WScript.CreateObject("InternetExplorer.Application")
objExplorer.Navigate "about:blank"
objExplorer.ToolBar = 0
objExplorer.StatusBar = 0
objExplorer.Width = 500
objExplorer.Height = 500
objExplorer.Left = 200
objExplorer.Top = 200
Do While (objExplorer.Busy)
Wscript.Sleep 300
Loop
objExplorer.Visible = 1
html = ""
html = html & "Determining OS. Please wait.."
objExplorer.Document.Body.InnerHTML = html
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & sComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
html = "<font size=4>PC Name: </font>" & sComputer & "<br><font size=4>OS: </font>" & objOperatingSystem.Caption & " " & objOperatingSystem.Version & "<br><br><br>"
objExplorer.Document.Body.InnerHTML = html
Next
htmlmsg = html & "<br><br>Getting IP info. Please wait...<br>"
objExplorer.Document.Body.InnerHTML = htmlmsg
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & sComputer & "\root\cimv2")
Set colAdapters = objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled = True")
For Each objAdapter in colAdapters
html = html & "Host name: " & objAdapter.DNSHostName & "<br>"
html = html & "DNS domain: " & objAdapter.DNSDomain & "<br>"
html = html & "DNS suffix search list: " & objAdapter.DNSDomainSuffixSearchOrder & "<br>"
html = html & "Description: " & objAdapter.Description & "<br>"
html = html & "Physical address: " & objAdapter.MACAddress & "<br>"
html = html & "DHCP enabled: " & objAdapter.DHCPEnabled & "<br>"
If Not IsNull(objAdapter.IPAddress) Then
For i = LBound(objAdapter.IPAddress) To UBound(objAdapter.IPAddress)
html = html & "IP address: " & objAdapter.IPAddress(i) & "<br>"
Next
End If
If Not IsNull(objAdapter.IPSubnet) Then
For i = LBound(objAdapter.IPSubnet) To UBound(objAdapter.IPSubnet)
html = html & "Subnet: " & objAdapter.IPSubnet(i) & "<br>"
Next
End If
If Not IsNull(objAdapter.DefaultIPGateway) Then
For i = LBound(objAdapter.DefaultIPGateway) To UBound(objAdapter.DefaultIPGateway)
html = html & "Default gateway: " & objAdapter.DefaultIPGateway(i) & "<br>"
Next
End If
html = html & "DHCP server: " & objAdapter.DHCPServer & "<br>"
If Not IsNull(objAdapter.DNSServerSearchOrder) Then
For i = LBound(objAdapter.DNSServerSearchOrder) To UBound(objAdapter.DNSServerSearchOrder)
html = html & "DNS server: " & objAdapter.DNSServerSearchOrder(i) & "<br>"
Next
End If
html = html & "Primary WINS server: " & objAdapter.WINSPrimaryServer & "<br>"
html = html & "Secondary WINS server: " & objAdapter.WINSSecondaryServer & "<br>"
html = html & "Lease obtained: " & objAdapter.DHCPLeaseObtained & "<br>"
html = html & "Lease expires: " & objAdapter.DHCPLeaseExpires & "<br><br><br>"
Next
objExplorer.Document.Body.InnerHTML = html