Visual Basic script to get Sysinfo

5 pts.
Tags:
Excel worksheets
Service packs
VBScript
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 ++

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Oh2abq
    [...] Visual Basic script to get Sysinfo [...]
    0 pointsBadges:
    report
  • Chippy088
    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.
    4,625 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following