Checking Registry - Forum

Forum Navigation
You need to log in to create posts and topics.

Checking Registry

I am trying to check the existence of a specific reg entry and if it's there.   When there isn't the existence of said key, the system throws an error (non valid key)

Is there a way to check to see if a key exists without throwing an error ?

Thanks

@rcohen

Yes, you can simply turn off the error display. For example:

ShowErrors "False"
RegistryRead "HKEY_CURRENT_USER" "Software\NeoSoft\NeoBook 5\Tools\NeoCommands" "[NCToolsYes]"
If "[NCToolsYes]" "<>" ""
    SetVar "[NCTools]" "checked"
EndIf
ShowErrors "True"

 

Hi @vadim,

yes, same suggestion from Zaeem ;-)   I was hoping for something more graceful ;-)   I generally like to keep ShowErrors to True in case there is a need for it, but I guess I can turn that back on when done testing...

Perhaps it's time for a "RegKeyExists" function?

Thanks

@rcohen

There are new commands that I haven't tried yet, maybe they can help (look in the debugger to see what comes back when the key you're looking for isn't there):
RegistryReadKeyList = Read the list of keys of the Windows registry section.
RegistryReadSectionList = Read a list of all Windows registry hives.

You can also use the dec_Plus 1.9 plugin (David Esperalta)
Check key: dec_SaberSiExisteUnaClave
Check the parameter: dec_SaberSiExisteUnValor (this command caused a hang of the IDE in my experience)

Thanks @Vadim,

I took your (and Zaeem's) suggestion and switched off error reporting.   At some point we'll have another solution too ;-)   I spotted the additional reg commands, but they didn't seem like they'd offer me what I was looking for.   I thought for a second about doing a ReadSectionList and looking for my key, but...  that was a long way around ;-0

Anyway, we got it working ;-)

Thanks for your input, as always.

Did you look at this plugin https://www.decsoftutils.com/Humm/Sites/Main/Views/Data/NeoPlugins/Plugins/npmine/index.html

rcohen has reacted to this post.
rcohen

@krakerman,

Thanks for the link, and no this is one I hadn't noticed, thanks for showing it to me.  Seems pretty cool, but I have already coded around the problem.  I will take a closer look at this one for when I'm needing more.

Thank you sir.

Krakerman has reacted to this post.
Krakerman

Hi @rcohen
I have in use a plugin to work with the registry.
It is not released yet, but if you are interested in buying the plugin, I could work on it ASAP,
If not, the plugin will be released one of these days.

These are some actions of the plugin:
• Set string
• Set Expanded string
• Set Dword
• Set Binary
• Set any string

• Get string
• Get Expanded string
• Get Dword
• Get Binary
• Get any string

• Exist key
• Exist value

• Delete key
• Delete value

• Enumerate keys
• Enumerate values

• Find key
• Find value

ALL actions are boolean as a result, this means that there won't be any error on screen.
Regards.

luishp and Vadim have reacted to this post.
luishpVadim

Hi @asleycruz,

The fact of the matter is that I don't mess with registry often and in fact this is the first time I'm doing this.  I normally keep registration details in an encrypted file.  I'm glad to see the "key exist" command though...  was thinking we should probably have that as part of the default reg commands in VNW.   This time, turning off error reporting worked

Thank you for the heads up.

AsleyCruz has reacted to this post.
AsleyCruz