Hello I am having problems with a VB Script this is what I want to achieve: 1) Check a machine if is active on the network 2) Find the current logged in user 3) Gather the Service Pack Version 4) Display all information into Excel 5) Highlight in redf which machines are online or offline 6) Highlight in red which machines need SP3+ I have managed to do most of the work
Copy of Script <Begin> On Error Resume Next
Set objExcel = CreateObject("Excel.Application") objExcel.Visible = True objExcel.Workbooks.Add intRow = 2 Const HKEY_LOCAL_MACHINE = &H80000002
objExcel.Cells(1, 1).Value = "Machine Name" objExcel.Cells(1, 2).Value = "Results" objExcel.Cells(1, 3).Value = "User Logged On"
Set Fso = CreateObject("Scripting.FileSystemObject") Set InputFile = fso.OpenTextFile("MachineList.Txt")
Do While Not (InputFile.atEndOfStream) HostName = InputFile.ReadLine
Set WshShell = WScript.CreateObject("WScript.Shell") Ping = WshShell.Run("ping -n 1 " & HostName, 0, True)
objExcel.Cells(intRow, 1).Value = UCase(HostName)
Select Case Ping Case 0 objExcel.Cells(intRow, 2).Value = "On Line" Case 1 objExcel.Cells(intRow, 2).Value = "Off Line" End Select
If objExcel.Cells(intRow, 2).Value = "Off Line" Then objExcel.Cells(intRow, 2).Interior.ColorIndex = 3 Else objExcel.Cells(intRow, 2).Interior.ColorIndex = 4
Set objRegistry = GetObject("winmgmts:\" & HostName & "rootdefault:StdRegProv") if err.number<>0 Then objExcel.Cells(intRow, 3).Value = "DENIED CHECK ADMIN GROUP" err.Clear Else strKeyPath = "SOFTWAREMicrosoftWindows NTCurrentVersionWinLogon" strValueName = "DefaultUserName" objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strValue objExcel.Cells(intRow, 3).Value = strValue End if End if
intRow = intRow + 1 Loop
objExcel.Range("A1:D1").Select objExcel.Selection.Interior.ColorIndex = 19 objExcel.Selection.Font.ColorIndex = 11 objExcel.Selection.Font.Bold = True objExcel.Cells.EntireColumn.AutoFit
MsgBox "Done" <end>
I am having problems gettng the SP info to display and highlight those fields in red that do not meet SP3 + levels.
Any help would be greatly beneficial - Thanks
Software/Hardware used:
Notepad ++
ASKED:
October 14, 2010 10:40 PM
UPDATED:
March 13, 2011 10:23 AM
In your VB code.
I would format the column to show negative numbers in red
return the comparison of ‘Service Pack > sp2′ value as true or false to this column and it will then show up as red.