6 Replies Latest reply on Apr 17, 2013 12:07 PM by Joe Piotrowski

    Using wildcards for Registry Keys in Component Templates

      Working with BSA 8.2.4.473 and I need to create a compliance job to search for a Windows service. The name of the service as implemented among the various servers can be almost anything and the location of the executable that runs the service can be installed almost anywhere. The only constant is the name of the executable for the service, lmgrd.exe. Because the executable is not installed in a standard location and because the name of the service can be anything, the closest thing to a constant that I can use for the compliance job in my component template is the Registry value of ImagePath in the HKLM\SYSTEM\CurrentControlSet\Services\service_name Registry key: that value will contain the path of the lmgrd.exe file (e.g. D:\Geomagic\lmgrd.exe or C:\Program Files\Macromedia\lmgrd.exe, etc.). But since service_name could be anything, I must use a variable, **. I have never used a wildcard for Registry value before but I would have thought that either

       

      "Registry Value:HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\**".Path contains lmgrd,exe

      OR

      "Registry Key:HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\**".Path contains "Registry Value:lmgrd.exe"."String Value (Windows)"

       

      would have worked but neither do. I have tried serveral other combinations as well, all unsuccessful. Of note, I first added and successfully ran discovery jobs for every Registry Key and Registry value permutation before I tested the my Compliance Rule but, again, nothing works.

       

      Bottom line, how can I write a Compliance Rule that will allow me to search for the executable lmgrd.exe in the ImagePath Registry Value regardless of the name of the service name or Registry Key that the ImagePath Registry Value is under?

        • 1. Re: Using wildcards for Registry Keys in Component Templates
          Joe Piotrowski

          I'd have to test on the registry key side, but this should work using the Services objects:

           

          exists "Windows Service:**" where

               "Binary Path (Windows)" contains "lmgrd.exe"

          end

          1 of 1 people found this helpful
          • 2. Re: Using wildcards for Registry Keys in Component Templates
            Niranjay Bharati

            Hi William ,

             

            The condition which you are executing will match all the occurences to be Imgrd.exe so the rule will never become compliant. Since it is a service and you would probably like to check only one occurence of Imgrd.exe under "Registry Value:HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\**" so the rule that joe has mentioned will work and become compliant.

             

            Thanks,

            -Niranjay.

            1 of 1 people found this helpful
            • 3. Re: Using wildcards for Registry Keys in Component Templates

              I tried the Compliance Rule "Windows Service:**"."Binary Path (Windows)" contains "lmgrd.exe" but it did not work. I even tried "Windows Service:*"."Binary Path (Windows)" contains "lmgrd.exe" (a single wildcard "*" that does not traverse paths) and that did not work, either; although that should not have worked.

               

              Interesting, it will work against my test server where I know the service name and do not use a wildcard but that is exactly the issue; the same executable (lmgrd.exe) has different service names and is installed in many different locations on servers throughout my infrastructure: I simply cannot specify every possible service name and/or executable location. Indeed, neither I nor anyone else even knows all the service name and executable locations that could be in our infrastructure. (I should add that the application was deployed many years ago without using BladeLogic.) Thus, this compliance rule must use path traversing wildcards (**).

               

              At this point, I am beginning to think that there may be an issue with using traversing wildcards with my particular version of BSA. We are using BSA 8.2.04.437. Have there been any reports of any problems.

               

              Otherwise, I am flummoxed. Over the last week or so, I have tried every possible combination I (and a few coworkers)could think of, some of which I would have been very surprised if they worked, But nothing has worked, including the above suggestion.

              • 4. Re: Using wildcards for Registry Keys in Component Templates
                Niranjay Bharati

                Did you try something like below?

                 

                exists "Registry Key:HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\**" where

                Path (Windows)" contains "lmgrd.exe"

                end

                 

                It should work in 8.2 as I have tested the similar condition on 8.2 version.

                • 5. Re: Using wildcards for Registry Keys in Component Templates
                  Joe Piotrowski

                  I am using 8.2 SP2. The syntax I gave you works fine for my environment.

                  • 6. Re: Using wildcards for Registry Keys in Component Templates
                    Joe Piotrowski

                    Keep in mind that the overall compliance rule with come back as Compliant (not bold). But the condition itself within the rule will show up as Red and Bold because it's failing on all the services except the one it finds.

                    rule1.jpg

                    rule2.jpg

                    This is still showing as a Compliant run, but the rule is highlighted in Red on the right.

                     

                    I changed the binary name as a test (above) and it correctly fails if it can't find it.