Code Script .co.uk

Home | Scripts | Tutorials | Disclaimer | Sitemap | Contact

   Get Machine Ip Address From Name
 

Vbscript / General / Get Machine Ip Address From Name

Set objShell = WScript.CreateObject("WScript.Shell")

getIP("localhost")

Function getIP(strComputer)

op = runCMD("ping " & strComputer & " -n 1")

op = Right(op,Len(op)-inStr(op,"["))

op = Left(op,inStr(op,"]")-1)

Wscript.Echo op

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