Taken from the MSDN website here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/wmi_tasks__networking.asp
I can't seem to get any of their samples working because they are incomplete and assuming I have done something that I havent. For example this code below should determine the IP address of the PC. But on my ASPX VB codepage I immediately get alerts that objWMIService, IPConfigSet and IPconfig are not declared. Similar declarations are needed in every one of their examples but I don't know what. Is there a page which tells me the complete code? All those WMI codes would be incredibly useful if only I didn't fall at the first hurdle.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/wmi_tasks__networking.asp
I can't seem to get any of their samples working because they are incomplete and assuming I have done something that I havent. For example this code below should determine the IP address of the PC. But on my ASPX VB codepage I immediately get alerts that objWMIService, IPConfigSet and IPconfig are not declared. Similar declarations are needed in every one of their examples but I don't know what. Is there a page which tells me the complete code? All those WMI codes would be incredibly useful if only I didn't fall at the first hurdle.
Code:
visual basic code:strComputer = "."
Set objWMIService = GetObject( _
"winmgmts:\\" & strComputer & "\root\cimv2")
Set IPConfigSet = objWMIService.ExecQuery _
("Select IPAddress from Win32_NetworkAdapterConfiguration ")
For Each IPConfig in IPConfigSet
If Not IsNull(IPConfig.IPAddress) Then
For i=LBound(IPConfig.IPAddress) _
to UBound(IPConfig.IPAddress)
WScript.Echo IPConfig.IPAddress(i)
Next
End If
Next