Need help with Verify registry pattern match
In an Online Kscript, in the Verify section of a task, I'm trying to use the Verify a registry pattern match step. If the registry key HKLM\SOFTWARE\Protector Suite exists or HKLM\SOFTWARE\Protector Suite QL exists, I want to go on and uninstall some software.
Here is the script step:
Verify that "HKLM\\SOFTWARE!=Protector Suite.*" matches.
And it succeeds on a machine where I know that registry key exists. So far, so good.
But this also succeeds:
Verify that HKLM\\SOFTWARE!=nonesuch" matches.
And there is no "nonesuch" key under HKLM\SOFTWARE.
So what is the correct syntax for using the Verify a registry pattern match to check the exists of a key that begins with "Protector Suite"? Sande
Here is the script step:
Verify that "HKLM\\SOFTWARE!=Protector Suite.*" matches.
And it succeeds on a machine where I know that registry key exists. So far, so good.
But this also succeeds:
Verify that HKLM\\SOFTWARE!=nonesuch" matches.
And there is no "nonesuch" key under HKLM\SOFTWARE.
So what is the correct syntax for using the Verify a registry pattern match to check the exists of a key that begins with "Protector Suite"? Sande
0 Comments
[ + ] Show comments
Answers (7)
Please log in to answer
Posted by:
snissen
13 years ago
Posted by:
RichB
13 years ago
Posted by:
snissen
13 years ago
In my first message in this thread, I was trying to pattern match against a registry key, which gets weird because in the pattern you have to escape those backslashes.
Now I'm doing something simpler, trying to pattern match against the value of a known registry entry within a known registry key. So try this:
Verify a registry pattern matches...
Key: HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName
Name: ComputerName
Value: CMC019[3-5][0-9]{4}.*
Match: value
In other words, I want to check if the ComputerName entry matches the regular expression CMC019[3-5][0-9]{4}. (Check if it starts with CMC019, followed by a 5 digit number in the 30000-59999 range, optionally followed by any character.)
So here's how I'm interpreting this task step: put your regular expression to match in one of the three parts, Key, Name, or Value; change Match to indicate which part you put the pattern into; fill in the other two fields with fixed text (not patterns). Am I close?
Now I'm doing something simpler, trying to pattern match against the value of a known registry entry within a known registry key. So try this:
Verify a registry pattern matches...
Key: HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName
Name: ComputerName
Value: CMC019[3-5][0-9]{4}.*
Match: value
In other words, I want to check if the ComputerName entry matches the regular expression CMC019[3-5][0-9]{4}. (Check if it starts with CMC019, followed by a 5 digit number in the 30000-59999 range, optionally followed by any character.)
So here's how I'm interpreting this task step: put your regular expression to match in one of the three parts, Key, Name, or Value; change Match to indicate which part you put the pattern into; fill in the other two fields with fixed text (not patterns). Am I close?
Posted by:
snissen
13 years ago
(I hate having to learn KBOX stuff by trial and error...)
OK, this is working:
Verify a registry pattern matches...
Key: HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName
Name: ComputerName
Value: ^CMC019[3-5][0-9]{4}.*$
Match: value
I'm hoping any valid regular expression will work; I plan to try the "Alternation construct" | later, as in: ^(CMC019|CMC110)[3-5][0-9]{4}.*$
Now, it's going to get trickier if the pattern I want to match on is part of the registry key, not the name or value, because I have to escape those backslashes in the registry key. Next time, I plan to try this:
Verify a registry pattern matches...
Key: HKLM\x5CSOFTWARE\x5CProtector Suite.*
Name:
Value:
Match: key
Any guidance along these lines would still be appreciated. Sande
OK, this is working:
Verify a registry pattern matches...
Key: HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName
Name: ComputerName
Value: ^CMC019[3-5][0-9]{4}.*$
Match: value
I'm hoping any valid regular expression will work; I plan to try the "Alternation construct" | later, as in: ^(CMC019|CMC110)[3-5][0-9]{4}.*$
Now, it's going to get trickier if the pattern I want to match on is part of the registry key, not the name or value, because I have to escape those backslashes in the registry key. Next time, I plan to try this:
Verify a registry pattern matches...
Key: HKLM\x5CSOFTWARE\x5CProtector Suite.*
Name:
Value:
Match: key
Any guidance along these lines would still be appreciated. Sande
Posted by:
snissen
12 years ago
Posted by:
jverbosk
12 years ago
This doesn't answer your question directly, but I'm wondering if there in an uninstall string in the registry that you can reference - if so, you can then use "msiexec /x {....string....}" to uninstall. I've used this in my environment via a batch command in the remediation section to uninstall programs, with a "verify file exists" statement simply pointing to a file in said program's directory (if it doesn't exist, the program isn't installed), and it's worked well enough run as the logged in user.
John
John
Posted by:
snissen
12 years ago
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.