[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 292
  • Last Modified:

I need a script

Not being that familar with scripts, I look to the experts for advice.  I need a script that will report a file version on a number of servers.  I have the following script that works well, but I have to OK through each server.  I would like to to output the results in a list or some kind of file.  

WScript.Echo "Server name" & vbTab & "File Version"
'WScript.Echo "-----------" & vbTab & "-----------------"

Const ForReading = 1
Set objDictionary = CreateObject("Scripting.Dictionary")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("C:\servers.txt", ForReading)
i = 0
Do Until objTextFile.AtEndOfStream
   strNextLine = objTextFile.Readline
   objDictionary.Add i, strNextLine
   i = i + 1
Loop
For Each objItem in objDictionary
   Set objFSO = CreateObject("Scripting.FileSystemObject")
   Wscript.Echo objDictionary.Item(objItem) & vbTab & objFSO.GetFileVersion _
("\\"& objDictionary.Item(objItem) & "\C$\Program Files\application\file.exe")                  

Next



Thanks
0
mchristo63
Asked:
mchristo63
  • 3
1 Solution
 
fulscherCommented:
The following is not tested, you may need to work a bit on it:

WScript.Echo "Server name" & vbTab & "File Version"
'WScript.Echo "-----------" & vbTab & "-----------------"

Const ForReading = 1
Const ForWriting = 2

Set objDictionary = CreateObject("Scripting.Dictionary")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("C:\servers.txt", ForReading)
Set objReportFile = objFSO.OpenTextFile("C:\report.txt", ForWriting)

i = 0
Do Until objTextFile.AtEndOfStream
   strNextLine = objTextFile.Readline
   objDictionary.Add i, strNextLine
   i = i + 1
Loop
For Each objItem in objDictionary
   Set objFSO = CreateObject("Scripting.FileSystemObject")
   objReportFile.WriteLine objDictionary.Item(objItem) & vbTab & objFSO.GetFileVersion _
("\\"& objDictionary.Item(objItem) & "\C$\Program Files\application\file.exe")                  

Next
0
 
fulscherCommented:
Ups - an explanation: This creates a file C:\report.txt (erases it if it is not empty) and writes your report into that file.
Hope this helps
J
0
 
mchristo63Author Commented:
Excellent!
0
 
fulscherCommented:
Thank you!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now