Registry problems

(imported topic written by sinucus)

I’m having some problems writing some relevance and I’m not sure what I’m doing wrong. I know I’ve read the proper why to handle this but I’m at a loss right now.

I need to check the registry to see if a 2 values exist and in a certain condition. If they don’t exist in that condition I want it to report as true. Here is what I have

if (not exists value “ActionCount” of key “HKEY_LOCAL_MACHINE\SOFTWARE\Tivoli” of registry) then true else if ((exists value “Version” whose (it as string = “5”) of key “HKEY_LOCAL_MACHINE\SOFTWARE\Tivoli” of registry) AND (value “ActionCount” of key “HKEY_LOCAL_MACHINE\SOFTWARE\Tivoli” of registry as integer > 2)) then false else true

So what I’m looking for is to see if the entire hive exists, if it doesn’t, true.

If the Version is != 5, true

If the Version is = 5 AND ActionCount > 2 = false, else true. I.e. if it’s 1 or 2 true

I keep running into problems with one of the values doesn’t exist. I’m getting the “Singular expression refers to nonexistent object.” errors. Thanks

(imported comment written by MattPeterson)

If one of those values or keys do not exist then your statment will not work. You could add a couple | statements so if those statements error then try the next statement. Try this:

q:

if

(
not

exists

value

“ActionCount”

of

key

“HKEY_LOCAL_MACHINE\SOFTWARE\Tivoli”

of

registry

|

true
)

then

true

else

if

((
exists

value

“Version”

whose

(
it

as

string

=

“5”
)

of

key

“HKEY_LOCAL_MACHINE\SOFTWARE\Tivoli”

of

registry

|

false
)

AND

(value

“ActionCount”

of

key

“HKEY_LOCAL_MACHINE\SOFTWARE\Tivoli”

of

registry

as

integer

2

|

false
))

then

false

else

true

A:
True

(imported comment written by sinucus)

thanks, I’ll give that a shot.