VBS: Check for file existence on a set of remote comuters.

Home Forums Scripting Windows Script Host VBS: Check for file existence on a set of remote comuters.

Viewing 1 post (of 1 total)
  • Author
  • Avatar
    ‘* Author: Guy Teverovsky
    ‘* The script enumerates the computer objects in a given OU,
    ‘* checks whether a computer is reachable over the network,
    ‘* and if yes, verifies the existence of a given file on the
    ‘* remote computer.
    ‘* Can be used for checking “flag” files like c:NotWorm or
    ‘* dll versions. I used it to verify that users got a specific update
    ‘* installed.

    strOUDN = “OU=Workstations,OU=Clients,DC=test,DC=net”

    Set objRootDSE = GetObject(”LDAP://RootDSE”)
    strClientsPath = “LDAP://” & strOUDN
    Set objClientsContainer = GetObject(strClientsPath)

    ‘The file we want to check
    strSearchFile = “c$Program FilesTestTest.exe”

    For Each objClient In objClientsContainer
    arClient= split(objClient.Name,”=”)
    strClient = arClient(1)
    If IsPingable(strClient) Then
    Set objFSO = CreateObject(”Scripting.FileSystemObject”)
    strSearchFileUNC = “\” & strClient & “” & strSearchFile
    If objFSO.FileExists(strSearchFileUNC) Then
    strSearchFileVer = objFSO.GetFileVersion(strSearchFileUNC)
    If strSearchFileVer <> “” Then
    End If
    WScript.Echo(”Computer ” & strClient & ” does not have the file in question”)
    End If
    WScript.Echo(”The client is not reachable…”)
    End If


    ‘* Function IsPingable(strHost)
    ‘* Returns True or False based on the output from ping.exe
    Function IsPingable(strHost)
    Set objShell = WScript.CreateObject(”WScript.Shell”)
    Set objExecObject = objShell.Exec(”cmd /c ping.exe -n 3 -w 1000 ” & strHost)
    Do While Not objExecObject.StdOut.AtEndOfStream
    strText = objExecObject.StdOut.ReadLine()
    If Instr(strText, “Reply”) > 0 Then
    ‘Wscript.Echo “Reply received.”
    IsPingable = True
    Exit Do
    End If
    If (IsPingable <> True) Then
    IsPingable = False
    End If
    End Function

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.