Forum Discussion

sastowe's avatar
sastowe
Super Contributor
12 years ago
Solved

ip address of test machine

Is there a wrapper or easy way to get the IP address and machine name of the computer that the test is being run on? Can't find it in my various aq... seeking. Someone might know off the top of the head.  Thanks.


  • Hello Stephanie,


    For the computer name you can use Sys.HostName. However there doesn't look like there's one for the IP address. 


    You can try using WMI to gather the IP address


    http://msdn.microsoft.com/en-us/library/aa394217(VS.85).aspx



    eg.


    Sub LogIPAddress


      strQuery = "select * from Win32_NetworkAdapterConfiguration where IPEnabled=True"


      Set colItems = GetObject("winmgmts:").ExecQuery(strQuery)


      Log.Message sys.HostName


      For Each objItem In colItems


        Log.Message(objItem.DNSHostName)


        Log.Message(objItem.IPAddress(0)) 


      Next 


    End Sub




    Cheers,


    Jackson

2 Replies



  • Hello Stephanie,


    For the computer name you can use Sys.HostName. However there doesn't look like there's one for the IP address. 


    You can try using WMI to gather the IP address


    http://msdn.microsoft.com/en-us/library/aa394217(VS.85).aspx



    eg.


    Sub LogIPAddress


      strQuery = "select * from Win32_NetworkAdapterConfiguration where IPEnabled=True"


      Set colItems = GetObject("winmgmts:").ExecQuery(strQuery)


      Log.Message sys.HostName


      For Each objItem In colItems


        Log.Message(objItem.DNSHostName)


        Log.Message(objItem.IPAddress(0)) 


      Next 


    End Sub




    Cheers,


    Jackson