How to Ping a List of Computers With VBScript

Written by jon evans
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to Ping a List of Computers With VBScript
Remote maintenance simplifies system administration. (Hemera Technologies/Photos.com/Getty Images)

If you are a system administrator, you likely perform system maintenance and backups on many computers. Most of these tasks can be done remotely, but only if the systems you are working on are powered on. Prior to beginning your scheduled maintenance, you can run a Visual Basic script that will allow you to ping the machines on your network.

Skill level:
Moderate

Other People Are Reading

Things you need

  • Network connection to remote machines
  • Visual Basic compiler
  • List of IP addresses for machines you wish to ping

Show MoreHide

Instructions

  1. 1

    Create a list of computers based on IP addresses. Enter only the IP addresses and only one per line. Save this list as a text file; for example, save the file as "c:\serverlist.txt"

  2. 2

    Create a Visual Basic script that calls the "c:\serverlist.txt" file as a source file. This script will also output the results to the file "c:\output.csv". Use the following code:

    dim strInputPath, strOutputPath, strStatus

    dim objFSO, objTextIn, objTextOut

    strInputPath = "c:\serverlist.txt") '- location of input

    strOutputPath = "c:\output.csv") '- location of output

    set objFSO = CreateObject("Scripting.FileSystemObject")

    set objTextIn = objFSO.OpenTextFile( strInputPath,1 )

    set objTextIn = objFSO.CreateTextFile( strOutputPath )

    objTextOut.WriteLine("computer,status")

    Do until objTextIn.AtEndOfStream = True

    strComputer = objTextIn.ReadLine
    
        if fPingTest( strComputer ) then
    
             strStatus = "UP"
    
        else
    
             strStatus = "DOWN"
    
        end if
    
        objTextOut.WriteLine(strComputer & "," & strStatus)
    

    loop

  3. 3

    Compile and execute the code. Review the contents of "c:\output.csv".

Don't Miss

Filter:
  • All types
  • Articles
  • Slideshows
  • Videos
Sort:
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the eHow.co.uk site, you consent to the use of cookies. For more information, please see our Cookie policy.