Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Grab File Version from Multiple Machine 1

Status
Not open for further replies.

Junbron

Technical User
Mar 5, 2012
15
NZ
I have a list of machines..
And im new to this scriptiing..
Does anyone know how to create a VBscript to generate FileVersion of a certain file and output to Xcell
Eg.. c$\Program Files\Java\jre6\bin\javaw.exe


 
Not sure if this will help but I thought I'd give it a try with my basic vbscript skills. It outputs to a text file though you can easily import this to Excel. Also, you need to run it as an admin account to access the remote PCs. I'm sure there are better ways of doing it, but this is what I came up with quickly

Code:
dim objFSO, strFile, strFilePath, OFile, oFile2, strPCNum, strOutputFile, strRemoteFile, strFileVersion, strOutText
Set objFSO = CreateObject("Scripting.FileSystemObject")
set objShell = CreateObject("WScript.Shell")

strFilePath = InputBox("Enter the file path to the file you wish to get the version of", "Enter the file path")

if strFilePath = "" then 
   wscript.echo "No file path supplied. Quitting Program"
   wscript.quit
end if

strInputFile = InputBox("Enter the file path to the file containing the list of PCs", "Enter the file path")

if strInputFile = "" then 
   wscript.echo "No file path supplied. Quitting Program"
   wscript.quit
end if

strOutputFile = InputBox("Enter the file path to write the results to", "Enter the file path")

if strOutPutFile = "" then 
   wscript.echo "No file path supplied. Quitting Program"
   wscript.quit
end if

if objFSO.FileExists(strInputFile) then
   set oFile=objFSO.OpenTextFile(strInputFile,1)
   set oFile2=objFSO.OpenTextFile(strOutputFile,8,True)
   do while not oFile.atendofstream
      strPCNum=oFile.readline    
      if Ping(strPCNum) then
         arrayFile = split(strFilePath, ":")
         strRemoteFile = "\\" + strPCNum + "\" + arrayFile(0) + "$" + arrayFile(1)
         strFileVersion = objFSO.GetFileVersion(strRemoteFile)
         strOutText = strRemoteFile + vbTab + strFileVersion
         oFile2.WriteLine(strOutText)
      end if   
   loop
else
   wscript.echo "File containing list of PCs does not exist. Quitting Program"
   wscript.quit
oFile.close
oFile2.Close
end if

Function Ping(PC)
   Set objWshScriptExec = objShell.Exec("ping.exe -n 1 " & PC)
   Set objStdOut = objWshScriptExec.StdOut

   awake=False
   Do Until objStdOut.AtEndOfStream
      strLine = objStdOut.ReadLine
      awake = awake Or InStr(LCase(strLine), "bytes=") > 0
   Loop
   Ping = awake
End Function
 
Deymmm !!! Ur amazing!!!
Thank you so much...

I pretty much just added one line for me to report the Offline machine as well..and all good..

Thanks u So much!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top