Obtaining an IP address using @WMI and WMIQUERY

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
#1
While you can use @IPADDRESS to obtain the IP address of a specific host, you can also use @WMI and WMIQUERY. Example;

Code:
echo %@wmi[root\cimv2,"SELECT ProtocolAddress FROM Win32_Pingstatus where address='jpsoft.com'"]
or

Code:
wmiquery root\cimv2 "SELECT ProtocolAddress FROM WIN32_Pingstatus where address='jpsoft.com'"
Yes, @IPADDRESS returns the IP address much faster than @WMI and WMIQUERY, but this is just an example of doing the same thing using an alternate method.

You can see the other properties of Win32_PingStatus by visiting http://msdn.microsoft.com/en-us/library/aa394350%28v=vs.85%29.aspx

Joe