Const HKEY_LOCAL_MACHINE = &H80000002 
Const FOR_WRITING = 2 
Const ForReading = 1 
 
Set objFso = CreateObject("Scripting.FileSystemObject") 
Set objShell = CreateObject("WScript.Shell") 
 
Set oList = objFso.OpenTextFile("clients.txt",ForReading) 
Do While Not oList.AtEndOfStream 
    strComputername = oList.ReadLine 
    If Left(strComputername,1) <> ";" Then 
        If HostOnline(strComputername) = True Then 
            Inventory(strComputername) 
        End If 
    End If 
Loop 

'========================================================================== 
 
Function Inventory(strComputername) 
    On Error Resume Next 
     
    objOS.OSArchitecture = ""
    Set oTextFile = objFso.OpenTextFile(strComputername & ".txt", FOR_WRITING, TRUE) 
     
    'oTextFile.WriteLine strComputername 
     
    Set objWMIService = GetObject("winmgmts:" _ 
     & "{impersonationLevel=impersonate}!\\" & strComputername & "\root\cimv2") 
  
    Set colOSes = objWMIService.ExecQuery("Select * from Win32_OperatingSystem") 
    For Each objOS in colOSes 
          oTextFile.WriteLine "Computer Name: " & objOS.CSName 
          oTextFile.WriteLine "Caption: " & objOS.Caption 
          oTextFile.WriteLine "Version: " & objOS.Version 
          oTextFile.WriteLine "Build Number: " & objOS.BuildNumber 
          oTextFile.WriteLine "Build Type: " & objOS.BuildType 
          oTextFile.WriteLine "OS Type: " & objOS.OSType 
	  oTextFile.WriteLine "OS Architecture: " & objOS.OSArchitecture
          oTextFile.WriteLine "Other Type Description: " & objOS.OtherTypeDescription 
          oTextFile.WriteLine "Service Pack: " & objOS.ServicePackMajorVersion & "." & objOS.ServicePackMinorVersion 
    Next 
     
    Set colProcs = objWMIService.ExecQuery("Select * from Win32_ComputerSystem") 
 
    For Each objItem in colProcs 
        oTextFile.WriteLine "Number of Processors: " & objItem.NumberOfProcessors 
    Next 
     
    oTextFile.WriteLine vbCrLf & "Applications:" 
 
    Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputername & "\root\default:StdRegProv") 
     
    strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" 
    objReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys 
 
    For Each subkey In arrSubKeys 
        strSubKeyPath = strKeyPath & "\" & subkey 
         
        strString = "DisplayName" 
        objReg.GetStringValue HKEY_LOCAL_MACHINE, strSubKeyPath, strString, strDisplayName 
         
        strString = "DisplayVersion" 
        objReg.GetStringValue HKEY_LOCAL_MACHINE, strSubKeyPath, strString, strDisplayVersion 
         
        strString = "Publisher" 
        objReg.GetStringValue HKEY_LOCAL_MACHINE, strSubKeyPath, strString, strDisplayPublisher 

        strDisplayName=Trim(strDisplayName) 
        strDisplayVersion=Trim(strDisplayVersion) 
        strDisplayPublisher=Trim(strDisplayPublisher)
        If strDisplayName <> "" Then 
            oTextFile.WriteLine strDisplayPublisher & ";" & strDisplayName & ";" & strDisplayVersion 
        End If 
    Next 

      strKeyPath = "SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall" 
      objReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys 
 
      For Each subkey In arrSubKeys 
          strSubKeyPath = strKeyPath & "\" & subkey 
           
          strString = "DisplayName" 
          objReg.GetStringValue HKEY_LOCAL_MACHINE, strSubKeyPath, strString, strDisplayName 
         
          strString = "DisplayVersion" 
          objReg.GetStringValue HKEY_LOCAL_MACHINE, strSubKeyPath, strString, strDisplayVersion 
         
          strString = "Publisher" 
          objReg.GetStringValue HKEY_LOCAL_MACHINE, strSubKeyPath, strString, strDisplayPublisher 

          strDisplayName=Trim(strDisplayName) 
          strDisplayVersion=Trim(strDisplayVersion) 
          If strDisplayName <> "" Then 
               oTextFile.WriteLine strDisplayPublisher & ";" & strDisplayName & ";" & strDisplayVersion 
          End If 
      Next 

    oTextFile.WriteLine "EOF" 
 
    objTextFile.close 

End Function 

'========================================================================== 
 
Function Output(sOutput) 
    WScript.echo Date() & " " & Time() & vbTab & sOutput 
End Function 

'========================================================================== 
 
Function HostOnline(strComputername) 
    Set sTempFolder = objFso.GetSpecialFolder(TEMPFOLDER) 
    sTempFile = objFso.GetTempName 
    sTempFile = sTempFolder & "\" & sTempFile 
 
    objShell.Run "cmd /c ping -n 2 -l 8 " & strComputername & ">" & sTempFile,0,True 
     
    Set oFile = objFso.GetFile(sTempFile) 
    set oTS = oFile.OpenAsTextStream(ForReading) 
    do while oTS.AtEndOfStream <> True 
        sReturn = oTS.ReadLine 
        if instr(sReturn, "Antwort")>0 then 
            HostOnline = True 
            Exit Do 
        End If 
    Loop 
     
    ots.Close 
    oFile.delete 
End Function 
 
'========================================================================== 
 
oList.Close 
Set objReg = Nothing 
Set objFso = Nothing 
