JohnRichard Posted September 2, 2008 Share Posted September 2, 2008 i have my WMI script which queries computer name then displays its IP Address but the message is not displaying as it should be. Need your help with this. the first script is WMI when exdcuted in command propmt it gives the IP address but the second code(AUTOIT script) it failed. code: WMI 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 AUTOIT Local $IPConfig $strComputer = Inputbox("IP Address", "Enter computer name to get its IP Address.") $ping = Ping($strComputer, 500) If $ping Then $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2") $IPConfigSet = $objWMIService.ExecQuery("Select IPAddress from Win32_NetworkAdapterConfiguration ") For $IPConfig in $IPConfigSet If $IPConfig.IPAddress <> "" Then For $i=UBound($IPConfig.IPAddress) to UBound($IPConfig.IPAddress) MsgBox(0, "", $IPConfig.IPAddress($i)) Next EndIf Next Else MsgBox(16, "Error", "Could not locate computer.") EndIf Link to comment Share on other sites More sharing options...
covaks Posted September 2, 2008 Share Posted September 2, 2008 Does this work for you? Local $IPConfig $strComputer = Inputbox("IP Address", "Enter computer name to get its IP Address.") $ping = Ping($strComputer, 500) If $ping Then $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2") $IPConfigSet = $objWMIService.ExecQuery("Select IPAddress from Win32_NetworkAdapterConfiguration ") For $IPConfig in $IPConfigSet If $IPConfig.IPAddress <> "" Then For $x = 0 to UBound($IPConfig.IPAddress) - 1 msgbox(0,"",$IPConfig.IPAddress($x)) Next EndIf Next EndIf Link to comment Share on other sites More sharing options...
JohnRichard Posted September 2, 2008 Author Share Posted September 2, 2008 thanks this works for me. but check out this script. why is that $objWMIService.IPAddress value is not returning any when i run the script? coz i wanted to include the IP Address value to the list but unfortunately it cannot give any value. #include <Array.au3> Local $res $strComputer = InputBox("Software", "Enter computer name.") $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $strComputer & "\root\cimv2") $colNicConfigs = $objWMIService.ExecQuery ("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True") For $objWMIService In $colNicConfigs $res &= $objWMIService.DHCPServer & @CRLF _ & $objWMIService.DNSHostName & @CRLF _ & $objWMIService.MACAddress & @CRLF _ & $objWMIService.WINSPrimaryServer & @CRLF _ & $objWMIService.IPAddress & @CRLF _ & $objWMIService.DNSDomain & @CRLF _ & $objWMIService.Description Next MsgBox(64, "Software List", $res) $aList = StringSplit(StringTrimRight($res, 1), @LF);StringTrimRight removes last @LF _ArrayDisplay($aList, "List") Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now