Help Modifying Script To Retrieve Last Windows Update Date and Time From Computers.

Home Forums Scripting Windows Script Host Help Modifying Script To Retrieve Last Windows Update Date and Time From Computers.

This topic contains 7 replies, has 3 voices, and was last updated by Avatar Shazam 6 years, 2 months ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • Avatar
    Shazam
    Member
    #161841

    Hi Everyone,

    I got this VBS code from this link below.

    http://community.spiceworks.com/how_to/show/3632-how-to-create-a-script-set-that-will-query-windows-systems-for-last-windows-update-date-and-time

    Can this script be modify to output the results to a CSV or Text file?

    Currently the results shows in a dialog box.

    Thanks!

    ‘Script pulls last Windows update info from registry of all computers specified in computers text file and echos on screen

    On Error Resume Next

    Set objGetComputerList = CreateObject(“Scripting.FileSystemObject”)
    Set fsoReadComputerList = objGetComputerList.OpenTextFile(“computers.txt”, 1, TristateFalse)
    aryServers = Split(fsoReadComputerList.ReadAll, vbCrLf)
    fsoReadComputerList.Close

    For Each strComputer In aryServers

    Const HKEY_LOCAL_COMPUTER = &H80000002

    strKeyPath = “SOFTWAREMicrosoftWindowsCurrentVersionWindowsUpdateAuto UpdateResultsInstall”
    strEntryName = “LastSuccessTime”
    Set objReg=GetObject(“winmgmts:{impersonationLevel=impersonate}!\” & _
    strComputer & “rootdefault:StdRegProv”)
    objReg.GetStringValue HKEY_LOCAL_COMPUTER, strKeyPath, strEntryName, strValue
    Wscript.Echo(strComputer & ” ” & strValue)

    Next[/CODE][CODE]’Script pulls last Windows update info from registry of all computers specified in computers text file and echos on screen

    On Error Resume Next

    Set objGetComputerList = CreateObject(“Scripting.FileSystemObject”)
    Set fsoReadComputerList = objGetComputerList.OpenTextFile(“computers.txt”, 1, TristateFalse)
    aryServers = Split(fsoReadComputerList.ReadAll, vbCrLf)
    fsoReadComputerList.Close

    For Each strComputer In aryServers

    Const HKEY_LOCAL_COMPUTER = &H80000002

    strKeyPath = “SOFTWAREMicrosoftWindowsCurrentVersionWindowsUpdateAuto UpdateResultsInstall”
    strEntryName = “LastSuccessTime”
    Set objReg=GetObject(“winmgmts:{impersonationLevel=impersonate}!\” & _
    strComputer & “rootdefault:StdRegProv”)
    objReg.GetStringValue HKEY_LOCAL_COMPUTER, strKeyPath, strEntryName, strValue
    Wscript.Echo(strComputer & ” ” & strValue)

    Next[/CODE]

    Avatar
    wullieb1
    Moderator
    #244358

    Re: Help Modifying Script To Retrieve Last Windows Update Date and Time From Computer

    Take out the wscript.echo and try this

    Const ForAppending = 8

    If objGetComputerList.FileExists(“c:update.txt”) Then
    Set objTextFile = objGetComputerList.OpenTextFile(“c:update.txt”, ForAppending, True)
    objTextFile.WriteLine(strComputer & ” ” & strValue)
    objTextFile.Close
    Else
    objGetComputerList.CreateTextFile(“c:update.txt”)
    Set objTextFile = objGetComputerList.OpenTextFile(“c:update.txt”, ForAppending, True)
    objTextFile.WriteLine(strComputer & ” ” & strValue)
    objTextFile.Close
    End If[/CODE]

    That should check if the file exists and if it does open it for appending and write your values. If it doesn’t exist it will then create it and open and write your values.

    There is probably a much quicker and easier way to do it and Rems is probably the man to assist.[CODE]Const ForAppending = 8

    If objGetComputerList.FileExists(“c:update.txt”) Then
    Set objTextFile = objGetComputerList.OpenTextFile(“c:update.txt”, ForAppending, True)
    objTextFile.WriteLine(strComputer & ” ” & strValue)
    objTextFile.Close
    Else
    objGetComputerList.CreateTextFile(“c:update.txt”)
    Set objTextFile = objGetComputerList.OpenTextFile(“c:update.txt”, ForAppending, True)
    objTextFile.WriteLine(strComputer & ” ” & strValue)
    objTextFile.Close
    End If[/CODE]

    That should check if the file exists and if it does open it for appending and write your values. If it doesn’t exist it will then create it and open and write your values.

    There is probably a much quicker and easier way to do it and Rems is probably the man to assist.

    Avatar
    Shazam
    Member
    #318943

    Re: Help Modifying Script To Retrieve Last Windows Update Date and Time From Computer

    Thank you so much for replying wullieb1.

    I added your code to my existing script. Nothing happens after I run it.

    Please look at the script below. Am I doing something wrong?

    ‘Script pulls last Windows update info from registry of all computers specified in computers text file and echos on screen

    On Error Resume Next

    Set objGetComputerList = CreateObject(“Scripting.FileSystemObject”)
    Set fsoReadComputerList = objGetComputerList.OpenTextFile(“update.txt”, 1, TristateFalse)
    aryServers = Split(fsoReadComputerList.ReadAll, vbCrLf)
    fsoReadComputerList.Close

    For Each strComputer In aryServers

    Const HKEY_LOCAL_COMPUTER = &H80000002

    strKeyPath = “SOFTWAREMicrosoftWindowsCurrentVersionWindowsUpdateAuto UpdateResultsInstall”
    strEntryName = “LastSuccessTime”
    Set objReg=GetObject(“winmgmts:{impersonationLevel=impersonate}!\” & _
    strComputer & “rootdefault:StdRegProv”)
    objReg.GetStringValue HKEY_LOCAL_COMPUTER, strKeyPath, strEntryName, strValue

    Const ForAppending = 8

    If objGetComputerList.FileExists(“c:update.txt”) Then
    Set objTextFile = objGetComputerList.OpenTextFile(“c:update.txt”, ForAppending, True)
    objTextFile.WriteLine(strComputer & ” ” & strValue)
    objTextFile.Close
    Else
    objGetComputerList.CreateTextFile(“c:update.txt”)
    Set objTextFile = objGetComputerList.OpenTextFile(“c:update.txt”, ForAppending, True)
    objTextFile.WriteLine(strComputer & ” ” & strValue)
    objTextFile.Close
    End If

    Next[/CODE][CODE]’Script pulls last Windows update info from registry of all computers specified in computers text file and echos on screen

    On Error Resume Next

    Set objGetComputerList = CreateObject(“Scripting.FileSystemObject”)
    Set fsoReadComputerList = objGetComputerList.OpenTextFile(“update.txt”, 1, TristateFalse)
    aryServers = Split(fsoReadComputerList.ReadAll, vbCrLf)
    fsoReadComputerList.Close

    For Each strComputer In aryServers

    Const HKEY_LOCAL_COMPUTER = &H80000002

    strKeyPath = “SOFTWAREMicrosoftWindowsCurrentVersionWindowsUpdateAuto UpdateResultsInstall”
    strEntryName = “LastSuccessTime”
    Set objReg=GetObject(“winmgmts:{impersonationLevel=impersonate}!\” & _
    strComputer & “rootdefault:StdRegProv”)
    objReg.GetStringValue HKEY_LOCAL_COMPUTER, strKeyPath, strEntryName, strValue

    Const ForAppending = 8

    If objGetComputerList.FileExists(“c:update.txt”) Then
    Set objTextFile = objGetComputerList.OpenTextFile(“c:update.txt”, ForAppending, True)
    objTextFile.WriteLine(strComputer & ” ” & strValue)
    objTextFile.Close
    Else
    objGetComputerList.CreateTextFile(“c:update.txt”)
    Set objTextFile = objGetComputerList.OpenTextFile(“c:update.txt”, ForAppending, True)
    objTextFile.WriteLine(strComputer & ” ” & strValue)
    objTextFile.Close
    End If

    Next[/CODE]

    Rems
    Rems
    Moderator
    #228318

    Re: Help Modifying Script To Retrieve Last Windows Update Date and Time From Computer

    For testing purpose remove the line: On Error Resume Next

    And the two Const variables below should be defined before the For-Next loop, and not within the loop.
    Const HKEY_LOCAL_COMPUTER = &H80000002[/CODE]
    [CODE]Const ForAppending = 8[/CODE]

    _
    [CODE]’ Script pulls last Windows update info from registry of
    ‘ all computers specified in computers text file and echos on screen

    Const HKEY_LOCAL_COMPUTER = &H80000002
    Const ForAppending = 8

    rem On Error Resume Next

    strKeyPath = “SOFTWAREMicrosoftWindowsCurrentVersionWindowsUpdate” _
    & “Auto UpdateResultsInstall”
    strEntryName = “LastSuccessTime”

    Set objGetComputerList = CreateObject(“Scripting.FileSystemObject”)

    Set fsoReadComputerList = objGetComputerList.OpenTextFile(“computers.txt”, 1)
    aryServers = Split(fsoReadComputerList.ReadAll, vbCrLf)
    fsoReadComputerList.Close

    Set objTextFile = objGetComputerList.OpenTextFile(“c:update.txt”, _
    ForAppending, True)

    For Each strComputer In aryServers

    Set objReg=GetObject(“winmgmts:{impersonationLevel=impersonate}!\” & _
    strComputer & “rootdefault:StdRegProv”)
    objReg.GetStringValue HKEY_LOCAL_COMPUTER, strKeyPath, _
    strEntryName, strValue
    objTextFile.WriteLine(strComputer & ” ” & strValue)

    Next
    objTextFile.Close

    wscript.quit[/CODE][CODE]Const HKEY_LOCAL_COMPUTER = &H80000002[/CODE]
    Const ForAppending = 8[/CODE]

    _
    [CODE]’ Script pulls last Windows update info from registry of
    ‘ all computers specified in computers text file and echos on screen

    Const HKEY_LOCAL_COMPUTER = &H80000002
    Const ForAppending = 8

    rem On Error Resume Next

    strKeyPath = “SOFTWAREMicrosoftWindowsCurrentVersionWindowsUpdate” _
    & “Auto UpdateResultsInstall”
    strEntryName = “LastSuccessTime”

    Set objGetComputerList = CreateObject(“Scripting.FileSystemObject”)

    Set fsoReadComputerList = objGetComputerList.OpenTextFile(“computers.txt”, 1)
    aryServers = Split(fsoReadComputerList.ReadAll, vbCrLf)
    fsoReadComputerList.Close

    Set objTextFile = objGetComputerList.OpenTextFile(“c:update.txt”, _
    ForAppending, True)

    For Each strComputer In aryServers

    Set objReg=GetObject(“winmgmts:{impersonationLevel=impersonate}!\” & _
    strComputer & “rootdefault:StdRegProv”)
    objReg.GetStringValue HKEY_LOCAL_COMPUTER, strKeyPath, _
    strEntryName, strValue
    objTextFile.WriteLine(strComputer & ” ” & strValue)

    Next
    objTextFile.Close

    wscript.quit[/CODE][CODE]Const ForAppending = 8[/CODE]

    _
    ‘ Script pulls last Windows update info from registry of
    ‘ all computers specified in computers text file and echos on screen

    Const HKEY_LOCAL_COMPUTER = &H80000002
    Const ForAppending = 8

    rem On Error Resume Next

    strKeyPath = “SOFTWAREMicrosoftWindowsCurrentVersionWindowsUpdate” _
    & “Auto UpdateResultsInstall”
    strEntryName = “LastSuccessTime”

    Set objGetComputerList = CreateObject(“Scripting.FileSystemObject”)

    Set fsoReadComputerList = objGetComputerList.OpenTextFile(“computers.txt”, 1)
    aryServers = Split(fsoReadComputerList.ReadAll, vbCrLf)
    fsoReadComputerList.Close

    Set objTextFile = objGetComputerList.OpenTextFile(“c:update.txt”, _
    ForAppending, True)

    For Each strComputer In aryServers

    Set objReg=GetObject(“winmgmts:{impersonationLevel=impersonate}!\” & _
    strComputer & “rootdefault:StdRegProv”)
    objReg.GetStringValue HKEY_LOCAL_COMPUTER, strKeyPath, _
    strEntryName, strValue
    objTextFile.WriteLine(strComputer & ” ” & strValue)

    Next
    objTextFile.Close

    wscript.quit[/CODE][CODE]’ Script pulls last Windows update info from registry of
    ‘ all computers specified in computers text file and echos on screen

    Const HKEY_LOCAL_COMPUTER = &H80000002
    Const ForAppending = 8

    rem On Error Resume Next

    strKeyPath = “SOFTWAREMicrosoftWindowsCurrentVersionWindowsUpdate” _
    & “Auto UpdateResultsInstall”
    strEntryName = “LastSuccessTime”

    Set objGetComputerList = CreateObject(“Scripting.FileSystemObject”)

    Set fsoReadComputerList = objGetComputerList.OpenTextFile(“computers.txt”, 1)
    aryServers = Split(fsoReadComputerList.ReadAll, vbCrLf)
    fsoReadComputerList.Close

    Set objTextFile = objGetComputerList.OpenTextFile(“c:update.txt”, _
    ForAppending, True)

    For Each strComputer In aryServers

    Set objReg=GetObject(“winmgmts:{impersonationLevel=impersonate}!\” & _
    strComputer & “rootdefault:StdRegProv”)
    objReg.GetStringValue HKEY_LOCAL_COMPUTER, strKeyPath, _
    strEntryName, strValue
    objTextFile.WriteLine(strComputer & ” ” & strValue)

    Next
    objTextFile.Close

    wscript.quit[/CODE]

    Avatar
    Shazam
    Member
    #318944

    Re: Help Modifying Script To Retrieve Last Windows Update Date and Time From Computer

    Rems;274260 wrote:
    For testing purpose remove the line: On Error Resume Next

    And the two Const variables below should be defined before the For-Next loop, and not within the loop.
    Const HKEY_LOCAL_COMPUTER = &H80000002[/CODE]
    [CODE]Const ForAppending = 8[/CODE]

    _
    [CODE]’ Script pulls last Windows update info from registry of
    ‘ all computers specified in computers text file and echos on screen

    Const HKEY_LOCAL_COMPUTER = &H80000002
    Const ForAppending = 8

    rem On Error Resume Next

    strKeyPath = “SOFTWAREMicrosoftWindowsCurrentVersionWindowsUpdate” _
    & “Auto UpdateResultsInstall”
    strEntryName = “LastSuccessTime”

    Set objGetComputerList = CreateObject(“Scripting.FileSystemObject”)

    Set fsoReadComputerList = objGetComputerList.OpenTextFile(“computers.txt”, 1)
    aryServers = Split(fsoReadComputerList.ReadAll, vbCrLf)
    fsoReadComputerList.Close

    Set objTextFile = objGetComputerList.OpenTextFile(“c:update.txt”, _
    ForAppending, True)

    For Each strComputer In aryServers

    Set objReg=GetObject(“winmgmts:{impersonationLevel=impersonate}!\” & _
    strComputer & “rootdefault:StdRegProv”)
    objReg.GetStringValue HKEY_LOCAL_COMPUTER, strKeyPath, _
    strEntryName, strValue
    objTextFile.WriteLine(strComputer & ” ” & strValue)

    Next
    objTextFile.Close

    wscript.quit[/CODE][/QUOTE]

    Thank you so much for working on this.

    The results did not complete though. It seems to stop if it reaches a computer that is shutdown.

    My computer list shows way over 100 computers and only less than 5 showed up on the results file. I think the script stops if it can’t reach a particular computer.

    Can the script be modify to move on to the next computer if a computer is not reachable?[CODE]Const HKEY_LOCAL_COMPUTER = &H80000002[/CODE]
    Const ForAppending = 8[/CODE]

    _
    [CODE]’ Script pulls last Windows update info from registry of
    ‘ all computers specified in computers text file and echos on screen

    Const HKEY_LOCAL_COMPUTER = &H80000002
    Const ForAppending = 8

    rem On Error Resume Next

    strKeyPath = “SOFTWAREMicrosoftWindowsCurrentVersionWindowsUpdate” _
    & “Auto UpdateResultsInstall”
    strEntryName = “LastSuccessTime”

    Set objGetComputerList = CreateObject(“Scripting.FileSystemObject”)

    Set fsoReadComputerList = objGetComputerList.OpenTextFile(“computers.txt”, 1)
    aryServers = Split(fsoReadComputerList.ReadAll, vbCrLf)
    fsoReadComputerList.Close

    Set objTextFile = objGetComputerList.OpenTextFile(“c:update.txt”, _
    ForAppending, True)

    For Each strComputer In aryServers

    Set objReg=GetObject(“winmgmts:{impersonationLevel=impersonate}!\” & _
    strComputer & “rootdefault:StdRegProv”)
    objReg.GetStringValue HKEY_LOCAL_COMPUTER, strKeyPath, _
    strEntryName, strValue
    objTextFile.WriteLine(strComputer & ” ” & strValue)

    Next
    objTextFile.Close

    wscript.quit[/CODE][/QUOTE]

    Thank you so much for working on this.

    The results did not complete though. It seems to stop if it reaches a computer that is shutdown.

    My computer list shows way over 100 computers and only less than 5 showed up on the results file. I think the script stops if it can’t reach a particular computer.

    Can the script be modify to move on to the next computer if a computer is not reachable?[CODE]Const ForAppending = 8[/CODE]

    _
    ‘ Script pulls last Windows update info from registry of
    ‘ all computers specified in computers text file and echos on screen

    Const HKEY_LOCAL_COMPUTER = &H80000002
    Const ForAppending = 8

    rem On Error Resume Next

    strKeyPath = “SOFTWAREMicrosoftWindowsCurrentVersionWindowsUpdate” _
    & “Auto UpdateResultsInstall”
    strEntryName = “LastSuccessTime”

    Set objGetComputerList = CreateObject(“Scripting.FileSystemObject”)

    Set fsoReadComputerList = objGetComputerList.OpenTextFile(“computers.txt”, 1)
    aryServers = Split(fsoReadComputerList.ReadAll, vbCrLf)
    fsoReadComputerList.Close

    Set objTextFile = objGetComputerList.OpenTextFile(“c:update.txt”, _
    ForAppending, True)

    For Each strComputer In aryServers

    Set objReg=GetObject(“winmgmts:{impersonationLevel=impersonate}!\” & _
    strComputer & “rootdefault:StdRegProv”)
    objReg.GetStringValue HKEY_LOCAL_COMPUTER, strKeyPath, _
    strEntryName, strValue
    objTextFile.WriteLine(strComputer & ” ” & strValue)

    Next
    objTextFile.Close

    wscript.quit[/CODE][/QUOTE]

    Thank you so much for working on this.

    The results did not complete though. It seems to stop if it reaches a computer that is shutdown.

    My computer list shows way over 100 computers and only less than 5 showed up on the results file. I think the script stops if it can’t reach a particular computer.

    Can the script be modify to move on to the next computer if a computer is not reachable?[CODE]’ Script pulls last Windows update info from registry of
    ‘ all computers specified in computers text file and echos on screen

    Const HKEY_LOCAL_COMPUTER = &H80000002
    Const ForAppending = 8

    rem On Error Resume Next

    strKeyPath = “SOFTWAREMicrosoftWindowsCurrentVersionWindowsUpdate” _
    & “Auto UpdateResultsInstall”
    strEntryName = “LastSuccessTime”

    Set objGetComputerList = CreateObject(“Scripting.FileSystemObject”)

    Set fsoReadComputerList = objGetComputerList.OpenTextFile(“computers.txt”, 1)
    aryServers = Split(fsoReadComputerList.ReadAll, vbCrLf)
    fsoReadComputerList.Close

    Set objTextFile = objGetComputerList.OpenTextFile(“c:update.txt”, _
    ForAppending, True)

    For Each strComputer In aryServers

    Set objReg=GetObject(“winmgmts:{impersonationLevel=impersonate}!\” & _
    strComputer & “rootdefault:StdRegProv”)
    objReg.GetStringValue HKEY_LOCAL_COMPUTER, strKeyPath, _
    strEntryName, strValue
    objTextFile.WriteLine(strComputer & ” ” & strValue)

    Next
    objTextFile.Close

    wscript.quit[/CODE]

    Thank you so much for working on this.

    The results did not complete though. It seems to stop if it reaches a computer that is shutdown.

    My computer list shows way over 100 computers and only less than 5 showed up on the results file. I think the script stops if it can’t reach a particular computer.

    Can the script be modify to move on to the next computer if a computer is not reachable?

    Avatar
    wullieb1
    Moderator
    #244359

    Re: Help Modifying Script To Retrieve Last Windows Update Date and Time From Computer

    Shazam;274261 wrote:
    Thank you so much for working on this.

    The results did not complete though. It seems to stop if it reaches a computer that is shutdown.

    My computer list shows way over 100 computers and only less than 5 showed up on the results file. I think the script stops if it can’t reach a particular computer.

    Can the script be modify to move on to the next computer if a computer is not reachable?

    Thanks for catching that Rems. I actually meant to say that. Doh!!!

    As for the new request then you will need to try and ping each system first and if you get a response then proceed if not then skip it.

    I do have one somewhere but I can’t find it at this time. Please check on Google somewhere as that will be where I got it :)

    Avatar
    Shazam
    Member
    #318945

    Re: Help Modifying Script To Retrieve Last Windows Update Date and Time From Computer

    Ok. I got it to capture all the computers. Leaving the…

    On Error Resume Next[/CODE]

    in the code.

    One more thing…

    Can the code be modified to space out the computer names and the date and time? Because when I try to import it in an excel file it’s all in one column. If it was more space out, then I can use the delimiter in excel to import it in properly.

    Is this possible?[CODE]On Error Resume Next[/CODE]

    in the code.

    One more thing…

    Can the code be modified to space out the computer names and the date and time? Because when I try to import it in an excel file it’s all in one column. If it was more space out, then I can use the delimiter in excel to import it in properly.

    Is this possible?

    Avatar
    Shazam
    Member
    #318946

    Re: Help Modifying Script To Retrieve Last Windows Update Date and Time From Computer

    Ok I was able to get it resolved. It was actually quite simple.

    I added more spaces between the &” “&.

    objTextFile.WriteLine(strComputer & ” ” & strValue)[/CODE]

    Thanks everyone for all your help. I really do appreciate it.

    And a special thanks to you Rems. You have helped me in the past before.

    Here is the code I ended up using.

    [CODE]Const HKEY_LOCAL_COMPUTER = &H80000002
    Const ForAppending = 8

    On Error Resume Next

    strKeyPath = “SOFTWAREMicrosoftWindowsCurrentVersionWindowsUpdate” _
    & “Auto UpdateResultsInstall”
    strEntryName = “LastSuccessTime”

    Set objGetComputerList = CreateObject(“Scripting.FileSystemObject”)

    Set fsoReadComputerList = objGetComputerList.OpenTextFile(“C:FolderLocationcomputers.txt”, 1)
    aryServers = Split(fsoReadComputerList.ReadAll, vbCrLf)
    fsoReadComputerList.Close

    Set objTextFile = objGetComputerList.OpenTextFile(“C:FolderLocationupdate.txt”, _
    ForAppending, True)

    For Each strComputer In aryServers

    Set objReg=GetObject(“winmgmts:{impersonationLevel=impersonate}!\” & _
    strComputer & “rootdefault:StdRegProv”)
    objReg.GetStringValue HKEY_LOCAL_COMPUTER, strKeyPath, _
    strEntryName, strValue
    objTextFile.WriteLine(strComputer & ” ” & strValue)

    Next
    objTextFile.Close

    wscript.quit[/CODE][CODE]objTextFile.WriteLine(strComputer & ” ” & strValue)[/CODE]

    Thanks everyone for all your help. I really do appreciate it.

    And a special thanks to you Rems. You have helped me in the past before.

    Here is the code I ended up using.

    Const HKEY_LOCAL_COMPUTER = &H80000002
    Const ForAppending = 8

    On Error Resume Next

    strKeyPath = “SOFTWAREMicrosoftWindowsCurrentVersionWindowsUpdate” _
    & “Auto UpdateResultsInstall”
    strEntryName = “LastSuccessTime”

    Set objGetComputerList = CreateObject(“Scripting.FileSystemObject”)

    Set fsoReadComputerList = objGetComputerList.OpenTextFile(“C:FolderLocationcomputers.txt”, 1)
    aryServers = Split(fsoReadComputerList.ReadAll, vbCrLf)
    fsoReadComputerList.Close

    Set objTextFile = objGetComputerList.OpenTextFile(“C:FolderLocationupdate.txt”, _
    ForAppending, True)

    For Each strComputer In aryServers

    Set objReg=GetObject(“winmgmts:{impersonationLevel=impersonate}!\” & _
    strComputer & “rootdefault:StdRegProv”)
    objReg.GetStringValue HKEY_LOCAL_COMPUTER, strKeyPath, _
    strEntryName, strValue
    objTextFile.WriteLine(strComputer & ” ” & strValue)

    Next
    objTextFile.Close

    wscript.quit[/CODE][CODE]Const HKEY_LOCAL_COMPUTER = &H80000002
    Const ForAppending = 8

    On Error Resume Next

    strKeyPath = “SOFTWAREMicrosoftWindowsCurrentVersionWindowsUpdate” _
    & “Auto UpdateResultsInstall”
    strEntryName = “LastSuccessTime”

    Set objGetComputerList = CreateObject(“Scripting.FileSystemObject”)

    Set fsoReadComputerList = objGetComputerList.OpenTextFile(“C:FolderLocationcomputers.txt”, 1)
    aryServers = Split(fsoReadComputerList.ReadAll, vbCrLf)
    fsoReadComputerList.Close

    Set objTextFile = objGetComputerList.OpenTextFile(“C:FolderLocationupdate.txt”, _
    ForAppending, True)

    For Each strComputer In aryServers

    Set objReg=GetObject(“winmgmts:{impersonationLevel=impersonate}!\” & _
    strComputer & “rootdefault:StdRegProv”)
    objReg.GetStringValue HKEY_LOCAL_COMPUTER, strKeyPath, _
    strEntryName, strValue
    objTextFile.WriteLine(strComputer & ” ” & strValue)

    Next
    objTextFile.Close

    wscript.quit[/CODE]

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.