how to read (Default) value in Registry Key in VBScript/JScript

tester picture tester · Aug 31, 2010 · Viewed 7.8k times · Source

I can read the value of the key name "UpdateCheck" under

HKEY_LOCAL_MACHINE\SOFTWARE\CCleaner\

with Shell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\CCleaner\UpdateCheck")

But I cannot read that of the key name "(Default)" .

Shell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\CCleaner\Default")

How to read it?

Answer

Steve picture Steve · Aug 31, 2010

Just pass the key name to RegRead and you'll get the default value. E.g.:

Shell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\CCleaner\")

NOTE: Notice the trailing \ in the regkey path. If that is missed out, it will try to read string value CCleaner from HKEY_LOCAL_MACHINE\SOFTWARE. Refer below .reg file snippet for more understanding.

[HKEY_LOCAL_MACHINE\SOFTWARE]
"CCleaner"="Some string value"

[HKEY_LOCAL_MACHINE\SOFTWARE\CCleaner]
@="some-default-value"