Working with non-existent values. Expected behavior? Bug? Workaround?

I’m working on pulling accurate Installed Applications information for Windows and macOS (because RegApps is useless :stuck_out_tongue: ) and I’ve found something interesting that’s alternately useful and annoying. Consider the following relevance:
(names of it) of keys of keys "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)
This gives me a long list of 150 Registry Key names. Now consider this slightly modified version:
(names of it, values "Installed" of it as string) of keys of keys "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)
This gives me 10 results…the 10 keys that actually have a value of “Installed”.

I’ve been using the “plurals everywhere” trick to avoid errors where something does not exist, but it does not seem to be working (or applicable) in this instance. How would I get all 150 Key names with a blank or null or something for those that do not actually have a value of “Installed”?

(Alternatively, this “feature” has turned out to be useful when looking for this same information on macOS. Applications on macOS are just special folders with a “.app” extension. Consider the following relevance:
(names of it as string, versions of it as string) of folders of (folders "/Applications"; folders "/System/Applications"; folders of (folders "/Applications"; folders "/System/Applications"))
This captures macOS Apps that are located at the root of the Applications folders or one level deeper, but it ignores those “normal” subfolders that contain Apps because the subfolders lack a “version”. Handy that I don’t have to manually exclude them, but now I may be missing a poorly written App that doesnt have a proper Version.)

If I understand it, you want to see all 150, and if any have a value of “Installed”, show it.

Perhaps an if-then-else construct, so you can iterate over all the keys of keys of Uninstall, and return the contents of the value “Installed” when present…

Yeah… I was thinking of that route, but was hoping for something more graceful. :slight_smile:

Also, there are time when I won’t know that some of the intended results don’t have that value and I’d have to set up an if/then for each of them. :scream:

I wonder if this is what that odd “if true of true” thing is for?

This is a case where I would use singulars to explicitly trigger the error, and then use the pipe operator “|” to handle the error. If the left side of the pipe triggers an error, the value from the right side of the pipe is substituted as the value

(name of it | "no name", value "Installed" of it as string | "no installed value") of keys of keys "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)

So, do that for every value EVAR?! (Or just know my data better and do that where needed…) :slight_smile:

Nice suggestion! Thanks!

@JasonWalker - That is some very fine relevance…

@straffin - You could use something like this to stash all the values:

(names of it,(names of it, it) of values of it) of keys of keys "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)

There are other interesting things in there, like uninstall strings…

@itsmpro92 - Trust me, I’m very familiar with the Uninstall keys (and much of the rest of the Windows Registry). This was just an example. :smile:

Ah well, it was an interesting exercise, nonetheless.

1 Like