Registry Key Values If They Exist

(imported topic written by SystemAdmin)

I’m trying to create an analysis that will look to see if one of two keys exists then output the value of “DisplayVersion” for which ever one does exists.

the keys are:

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Cisco IP Communicator

or

HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Cisco IP Communicator

What I have so far is:

(exists key “HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Cisco IP Communicator” of native registry) OR (exists key “HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Cisco IP Communicator” of native registry)

This get me a true/false

I can use this:

value “DisplayVersion” of key “HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Cisco IP Communicator” of native registry as string

To pull the value of one or the other key.

What is need is to combine everything so that it looks for either key and gives me the value of whatever one it finds. If nothing is found then output “not installed”

Is this possible?

This is what I thought would work:

q: if (exists key “HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Cisco IP Communicator” of native registry) OR if (exists key “HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Cisco IP Communicator” of native registry) then (value “DisplayVersion” of key “HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Cisco IP Communicator”) of native registry as string OR (value “DisplayVersion” of key “HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Cisco IP Communicator”) of native registry as string else “”

E: This expression could not be parsed.

thanks,

Baraq

Console version 8.1.551.0 with DSS-SAM Version 1.3.1.597

(imported comment written by SystemAdmin)

I think you’re looking for something like this …

if ((exists key “HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Cisco IP Communicator” of native registry)) then (value “DisplayVersion” of key “HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Cisco IP Communicator” of native registry as string) else (if (exists key “HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Cisco IP Communicator” of registry) then (value “DisplayVersion” of key “HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Cisco IP Communicator” of registry as string) else (""))

The Basic form is “If () then () else (if () then () else (FALSE))”

(imported comment written by SystemAdmin)

thanks Tim, that worked just fine for me.

-baraq

Console version 8.1.551.0 with DSS-SAM Version 1.3.1.597