Find string line in .reg file

(imported topic written by zouminyi91)

While I am use this analysis to find SYSname string line and display the whole line, but the result is

What’s the prblem? Thx

if exists file (“C:\home\Test\ABC.reg”) then following texts of firsts ““SYSname”” of lines whose (it contains ““SYSname””) of file(“C:\home\Test\ABC.reg”) else “N/A”

The reg file content:

Windows Registry Editor Version 5.00

HKEY_LOCAL_MACHINE\SOFTWARE\Test\AB

HKEY_LOCAL_MACHINE\SOFTWARE\Test\AB\TEMP

“SYSname”=“ComputerName”

(imported comment written by NoahSalzman)

q: lines of file “c:\test.txt”

A: Windows Registry Editor Version 5.00

A:

A:

HKEY_LOCAL_MACHINE\SOFTWARE\Test\AB

A:

A:

HKEY_LOCAL_MACHINE\SOFTWARE\Test\AB\TEMP

A: “SYSname”=“ComputerName”

T: 0.312 ms

I: plural file line

q: if exists file (“C:\test.txt”) then following texts of firsts “SYSname%22=” of lines whose (it contains “SYSname”) of file(“C:\test.txt”) else “N/A”

A: “ComputerName”

T: 0.411 ms

I: plural string

In version 8.0 and up you can get around the “if exists” annoyance by doing this:

q: following text of firsts “SYSname%22=” of lines whose (it contains “SYSname”) of file(“C:\test.txt”) | “N/A”

A: “ComputerName”

(imported comment written by MarkA.Stevens)

I’m keen on regular expressions, and similar to Noah’s solution:

if exists file (“C:\temp\ABC.reg”) then if (exists matches (regex “^%22SYSname%22=(.)$") of (lines of file “C:\temp\ABC.reg” as string)) then (parenthesized part 1 of (matches (regex "^%22SYSname%22=(.)$”) of (lines of file “C:\temp\ABC.reg” as string))) else (“No Entry”) else “No File”

… Mark

(imported comment written by zouminyi91)

Hi, Thanks for your info,

I tested, but still failed. I am using Bigfix 7.2.5.22.

For Noah’s script reported

For stevenam’s reported No Entry.

(imported comment written by MarkA.Stevens)

I do know there are some strange differences between 7.2.x and 8.1.x, as I have numerous pieces of code that no longer work. However, I no longer have access to 7.2.

This is the file I used, having borrowed it from your post above. Please note, I am running Cygwin on a Windows laptop, as I am by nature and training a Unix SA.

$ cat /cygdrive/c/temp/ABC.reg

Windows Registry Editor Version 5.00

HKEY_LOCAL_MACHINE\SOFTWARE\Test\AB

HKEY_LOCAL_MACHINE\SOFTWARE\Test\AB\TEMP

“SYSname”=“ComputerName”

$

So, when I run my code in the Windows QnA GUI, I get the following:

“ComputerName”

Evaluates to singular object of type string

… Mark

(imported comment written by NoahSalzman)

zouminyi,

Please paste the result (or partial result) of “lines of file ABC.reg” so we can see why it is not matching.

Also does SYSName appear more than once in the file?