Sunday, February 7, 2010

VBSCRIPT FILE VERSION ON LIST OF SYSTEMS TO EXCEL


Set Fso = CreateObject("Scripting.FileSystemObject")

Set InputFile = fso.OpenTextFile("MachineList.Txt")

Do While Not (InputFile.atEndOfStream)

strComputer = InputFile.ReadLine

Set objExcel = CreateObject("Excel.Application")

objExcel.Visible = True

objExcel.Workbooks.Add

intRow = 2
objExcel.Cells(1, 1).Value = "System Name"

objExcel.Cells(1, 2).Value = "Version"

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colFiles = objWMIService.ExecQuery _
    ("Select * from CIM_Datafile Where Name = 'c:\\windows\\system32\\mshtml.dll'")

For Each objFile in colFiles
objExcel.Cells(intRow, 2).Value = objFile.Version
objExcel.Cells(intRow, 1).Value = strComputer


objExcel.Range("A1:B1").Select

objExcel.Selection.Interior.ColorIndex = 19

objExcel.Selection.Font.ColorIndex = 11

objExcel.Selection.Font.Bold = True

objExcel.Cells.EntireColumn.AutoFit

 Next
loop

Set objSheet = objExcel.ActiveWorkbook.Worksheets(1)

Set objRange = objExcel.Range("B1")

objRange.Sort objRange,1,,,,,,1

' loop

MsgBox "Done"

''''''''''''''''''''''''''''''' THIS SCRIPT IS NOT WORKING AS EXPECTING IT IS OPENING MANY EXCEL FILES WITH CORRECT OUTPUT.. ANYWAY IT MIGHT USEFULL TO ME
-------------------
Thanks,

Mike Ditka  - "If God had wanted man to play soccer, he wouldn't have given us arms."

1 comment:

lauren said...

I am new to VB Script so do not know much of the code.I was searching for same and as you provided the code can you please add some brief comments to explain it.Thanks
digital signature certificate