thanks for allowing me to join this forum
the given below a vbs script which i googled and got which will take input from a text file compare with wmi for patches and gives output whether patches are installed or not…
now i want to make some modifications in the script:-
(a) the PCs hostname should me taken automatically from host commad and user no need to enter hostname
(b) Instead of showing output in open exel file, i want the output to be redirected to some csv file.
thanks in advance
the script follows :-
strComputer = InputBox (“Enter Machine Name”)
Set objExcel = CreateObject(“Excel.Application”)
objExcel.Visible = True
objExcel.Workbooks.Add
intRow = 2
objExcel.Cells(1, 1).Value = “HotFix”
objExcel.Cells(1, 2).Value = strHotFixId & ” Install Date”
Set Fso = CreateObject(“Scripting.FileSystemObject”)
Set InputFile = fso.OpenTextFile(“patches.Txt”)
Do While Not (InputFile.atEndOfStream)
strHotFixId = InputFile.ReadLine
Set objWMIService = GetObject(“winmgmts:\\” & strComputer & “\root\cimv2”)
Set colItems = objWMIService.ExecQuery( _
“Select * from Win32_QuickFixEngineering Where HotFixID ='” & strHotFixId & “‘”)
If colItems.Count > 0 Then
For Each objItem In colItems
objExcel.Cells(intRow, 1).Value = strHotFixId
objExcel.Cells(intRow, 2).Value = objItem.InstalledOn
Next
Else
objExcel.Cells(intRow, 1).Value = strHotFixId
objExcel.Cells(intRow, 2).Value = “Not Installed”
If objExcel.Cells(intRow, 2).Value = “Not Installed” Then
objExcel.Cells(intRow, 1).Font.ColorIndex = 3
objExcel.Cells(intRow, 2).Font.ColorIndex = 3
Else
End If
End If
intRow = intRow + 1
Loop
objExcel.Range(“A1:B1”).Select
objExcel.Cells.HorizontalAlignment = 2
objExcel.Selection.Interior.ColorIndex = 19
objExcel.Selection.Font.ColorIndex = 11
objExcel.Selection.Font.Bold = True
objExcel.Cells.EntireColumn.AutoFit
MsgBox “Done”
1 Answer