1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Obtaining an IP address using @WMI and WMIQUERY

Discussion in 'T&T - Functions' started by Joe Caverly, Feb 14, 2014.

  1. Joe Caverly

    Joined:
    Aug 28, 2009
    Messages:
    659
    Likes Received:
    8
    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
     

Share This Page