VBS help

Discussion in 'Software' started by amarques, Apr 24, 2006.

  1. amarques

    amarques Private E-2

    Being a newbie to VBS this is posing some trouble for me, but I am hoping someone who knows VBS can help me out.

    I have compiled a vbs script that will go out and ping machines from a text file. If the machine replies then I get a message that the computer responded to ping. If no reply then computer did not respond to ping.

    I would like to take this to then next level and if the computer replies, tell me what version of the operating system is running. IE Windows XP, Windows 2003 Enterprise, Windows 2003 Standard ect...

    Any help someone could provide would be greatly appreciated.

    Here is what I have so far:
    ************************************************
    On Error Resume Next

    'Initialize global constants and variables.
    Const FOR_READING = 1
    g_strHostFile = "computers.txt"
    strMyTextVariable = "results.txt"

    'Read computer names for install from text file.
    Set objFSO = CreateObject("Scripting.FileSystemObject")

    If objFSO.FileExists(g_strHostFile) Then

    Set objTextStream = objFSO.OpenTextFile(g_strHostFile, FOR_READING)

    Else

    WScript.Echo "Input file " & g_strHostFile & " not found."

    WScript.Quit

    End If

    'Loop through list of computers and perform tasks on each.
    Do Until objTextStream.AtEndOfStream
    g_strComputer = objTextStream.ReadLine

    'Ping host to ensure that it is accessible.
    blnPing = PingHost
    If blnPing = True Then

    Wscript.Echo g_strComputer & " responded to ping."

    Else

    WScript.Echo g_strComputer & " did not respond to ping."

    End If

    Loop

    objTextStream.Close

    '******************************************************************************

    Function PingHost

    Set objShell = CreateObject("WScript.Shell")
    Set objExec = objShell.Exec("ping -n 2 -w 1000 " & g_strComputer)
    strPingResults = LCase(objExec.StdOut.ReadAll)
    If InStr(strPingResults, "reply from") Then
    PingHost = True
    Else
    PingHost = False
    End If

    End Function

    '******************************************************************************
     
  2. Kodo

    Kodo SNATCHSQUATCH

    I would look into using WinInet.dll for this.
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds