Re: Script to get installed software and server applications on remote servers

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Richard Mueller [MVP] (rlmueller-NOSPAM_at_ameritech.NOSPAM.net)
Date: 03/25/04


Date: Thu, 25 Mar 2004 11:43:18 -0600

A A wrote:

>
> How can i run this VBS script for many remote servers at the same time,i
think with input txt file but how???
>
> Thanks for your time.
> Greetings,
> A.A
>
>
> -------------------------
> Set objFSO = CreateObject("Scripting.FileSystemObject")
> Set objTextFile = objFSO.CreateTextFile("c:\scripts\software.tsv", True)
> strComputer = "."
> Set objWMIService = GetObject("winmgmts:" _
> & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
> Set colSoftware = objWMIService.ExecQuery _
> ("Select * from Win32_Product")
> objTextFile.WriteLine "Name" & vbtab & _
> "Vendor" & vbtab & "Version"
> For Each objSoftware in colSoftware
> objTextFile.WriteLine objSoftware.Name & vbtab & _
> objSoftware.Vendor & vbtab & _
> objSoftware.Version
> Next
> objTextFile.Close
>
> -------------------------

Hi,

I used the code below. The file Machines.txt has the NetBIOS name of the
machines to report on, one machine name per line:

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objInputFile = objFSO.OpenTextFile("c:\MyFolder\Machines.txt", 1)
Set objOutputFile = objFSO.OpenTextFile("c:\MyFolder\Software.txt", 2, True,
0)

objOutputFile.WriteLine "Computer" & vbTab & "Name" & vbtab & _
  "Vendor" & vbtab & "Version"

Do Until objInputFile.AtEndOfStream
  strComputer = Trim(objInputFile.ReadLine)
  If strComputer <> "" Then
    Set objWMIService = GetObject("winmgmts:" _
      & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    Set colSoftware = objWMIService.ExecQuery _
      ("Select * from Win32_Product")
    For Each objSoftware in colSoftware
      objOutputFile.WriteLine strComputer & vbTab & objSoftware.Name _
        & vbtab & objSoftware.Vendor & vbtab & objSoftware.Version
    Next
  End If
Loop
objInputFile.Close
objOutputFile.Close
Wscript.Echo "Done"

-- 
Richard
Microsoft MVP Scripting and ADSI
HilltopLab web site - http://www.rlmueller.net
--