Registry search

Anything VBScript-related, including Windows Script Host, WMI, ADSI, and more.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
jvierra
Posts: 14578
Joined: Tue May 22, 2007 9:57 am
Answers: 1
Been upvoted: 1 time
Contact:

Registry search

Post by jvierra »

You need to step through it with the debugger and inspect the arguments.

There is something you are not telling me or there is somefundamental issue with the computer names.


I think this could be the issue:

replace the functio with the following version.

In the original example I had defined HKLM as a Const but I don't see it in your code. It should be a pass through anyway.

Code: Select all

	
Function ListSubKeys( sComputer, iKey, strKey, sKeyLookup, sKeyContent)
    On Error GoTo 0 ' be sure error cause us to quit.
    Set objReg = GetObject("winmgmts:" & sComputer & "rootdefault:StdRegProv") 
    objReg.EnumKey HKLM, strKey, arrSubkeys
    If IsArray(arrSubkeys) Then
        For Each strSubkey In arrSubkeys
            objReg.EnumValues iKey,strKey & "" & strSubkey,arrValues,arrTypes
            If isArray(arrValues) Then
                For i = 0 To Ubound(arrValues)
                    Select Case arrTypes(i)
                        Case REG_SZ 
                            If arrValues(i) = sKeyLookup Then
                                objReg.GetStringValue iKey, strKey & "" & strSubkey, arrValues(i), strValue1
                                If InStr(strValue1, sKeyContent) Then 
                                    'WScript.Echo "REG_SZ[ & arrValues(i)  & ]" & "[ & strValue1 & ]"
                                    ListSubKeys = strValue1
                                    Exit Function ' we got teh match so return with it
                                End If
                            End If
                        Case Else ' only interested in strings right now
                        'WScript.Echo  arrTypes(i)
                    End Select
                Next
            End If
            ListSubKeys = ListSubKeys( iKey, strkey & "" & strSubKey, sKeyLookup, sKeyContent)
            If Not IsEmpty( ListSubKeys ) Then
                Exit Function
            End If
        Next
      End If
End Function
	
Did you write this script or is it something someone gave to you?

If you didn't write it perhaps it soes not work the way you think.

I cannot vouch for the remainder of the code as there is no way for me to test this. You need to run it under the debugger on the target system.


jvierra
Posts: 14578
Joined: Tue May 22, 2007 9:57 am
Answers: 1
Been upvoted: 1 time
Contact:

Registry search

Post by jvierra »

You say it fails on teh second computer but not the first.

I can run it repeatedly with no issues.

Looking more closely at you other code I see nbumerous coding errors that you are not catching. The "Case" statement is not correct for all platforms.

You added my function but did not remove the old registry code so it is duplicated and it conflicts.

YOu canb't just arbitrarily add code into a file. The registry calls need to be done in a compatible way.

Remve the duplicate code and you should be able to debug this and get it working.,


User avatar
fr3288
Posts: 23
Joined: Sun Jan 28, 2007 1:37 am

Registry search

Post by fr3288 »

uploads/7819/CheckedPCs.zipI found it! Because we discovered the conflict between the two registry searches I went back to the script where we initially were getting the Memory is locked error. Under both registry searches we had For Each strSubkey In arrSubkeys. I changed all the instances for the search under the Uninstall key to strSubKeyA and arrSubkeysA. This fixed the problem. Attached is the output file so you can see what is produced. Now I will create the other functions to include the other Office patches. After I complete the script I will post it for the benefit of everybody. Thaks a million!
FR

jvierra
Posts: 14578
Joined: Tue May 22, 2007 9:57 am
Answers: 1
Been upvoted: 1 time
Contact:

Registry search

Post by jvierra »

Here is how to use an array.

aPatches = Array( _ "KB948988", _ "KB946648", _ "KB950974", _ "KB951066", _ "KB952954", _ "KB953838", _ "KB921596", _ "KB951548", _ "KB954464", _ "KB955439", _ "KB944338-v2" _)

For Each patch in aPatches
' process teh patch
Next

User avatar
fr3288
Posts: 23
Joined: Sun Jan 28, 2007 1:37 am

Registry search

Post by fr3288 »

I know it is harder to check for patches this way and I know there are different tools available to do this but since I have no access to them I have to find a work around to check for things like this.

Anyway, I try this script you just post it and see how it goes.

Thanks again.

User avatar
fr3288
Posts: 23
Joined: Sun Jan 28, 2007 1:37 am

Registry search

Post by fr3288 »

I ran your script . It found Windows and Media Player patches but not Office patches. Probably this method looks only under the Uninstall folder of the registry.

User avatar
fr3288
Posts: 23
Joined: Sun Jan 28, 2007 1:37 am

Registry search

Post by fr3288 »

I'm checking for Office 2003 patches. Here is one of them as it is return from my script:

Security Update for Word 2003 (KB954464): WINWORD

jvierra
Posts: 14578
Joined: Tue May 22, 2007 9:57 am
Answers: 1
Been upvoted: 1 time
Contact:

Registry search

Post by jvierra »

On all of my machines that I am testing it finds that KB perfectly.

[Security Update for Microsoft Office Word 2003 (KB954464)] Type:1 ArticleID:954464

If you know the UUID I can scan for it alone on a list of servers. This is very fast.


jvierra
Posts: 14578
Joined: Tue May 22, 2007 9:57 am
Answers: 1
Been upvoted: 1 time
Contact:

Registry search

Post by jvierra »

This works on every machine I have tried it on. It also correctly reports that it is not installed on a machine where it is in the registry but has been uninstalled or superceded.

This is a simple test script wit hno functions and only two arguments at the top for testing.

It is essentially the Microsoft SDK code for checking for patches.

Code: Select all

	
' find specific update
sComputer = "LOCALHOST"
matchID = "954464" 'KB954464
	
Set updateSession = CreateObject("Microsoft.Update.Session", sComputer)
Set updateSearcher = updateSession.CreateupdateSearcher()
	
WScript.Echo "Searching for updates..." & vbCRLF
	
Set searchResult = updateSearcher.Search("IsInstalled=1") ' and Type='Software'")
	

WScript.Echo "List of applicable items on the machine:"
	
For I = 0 To searchResult.Updates.Count-1
    Set update = searchResult.Updates.Item(I)
    For Each article In update.KbArticleIDs
             
             If article = matchID Then
                WScript.Echo "[ & update.Title & ]"
                WScript.Echo vbTab & "Type:" & update.Type
                WScript.Echo vbTab & "ArticleID:" & article 
                WScript.Quit
             End If
    Next
Next

User avatar
fr3288
Posts: 23
Joined: Sun Jan 28, 2007 1:37 am

Registry search

Post by fr3288 »

Sorry your post came in while I was writing mine. Anyway, I just tried your lates code now and it did not return any results. I checked the Add/Remove programs console and it shows KB954464.

Locked