Code Script .co.uk

Home | Scripts | Tutorials | Disclaimer | Sitemap | Contact

   Get Machine Ip Address
 

Vbscript / General / Get Machine Ip Address

Get the IP address of a server or workstation using the response from a command line ping.



Function getIP(strComputer)

strOut = runCMD("ping " & strComputer & " -n 1")
strOut = Right(strOut,Len(strOut)-inStr(strOut,"["))
strOut = Left(strOut,inStr(strOut,"]")-1)

getIP = strOut    

End Function

Function runCMD(strRunCmd)
 
 Set oExec = objShell.Exec(strRunCmd)
 
 strOut = ""

 Do While Not oExec.StdOut.AtEndOfStream
  strOut = strOut & oExec.StdOut.ReadLine()
 Loop

 runCMD = strOut

End Function





Please note that a disclaimer applies to any code on this page.
 
   Actions
  Go Back
  Bookmark
  Print Page


   Menu
 
- Links
- Reference
- Script Editors
- Tutorials