I am trying to read registry key value in VB.Net with not much luck.
Here is the key in question:
HKEY_LOCAL_MACHINE\SOFTWARE\Intel\Setup and Configuration Software\INTEL-SA-00086 Discovery Tool\System Status
Here is the code snippet
Dim key As String = "SOFTWARE\Intel\Setup And Configuration Software\INTEL-SA-00086 Discovery Tool\System Status"
Dim val As String = "System Risk"
MessageBox.Show(Microsoft.Win32.Registry.LocalMachine.GetValue(key, val, Nothing))
So far I've been able to figure out that the issue is spaces between the key names as I can get the value of other keys where name doesn't have spaces.
I've tried escaping registry key path in VB.Net but it is either returning the value name in itself or throwing an exception.
This isn't because of backspace or slashes as the following works
Dim key As String = "SOFTWARE\Intel\PSIS\PSIS_DECODER"
Dim val As String = "SomeKey"
MessageBox.Show(Microsoft.Win32.Registry.LocalMachine.GetValue(key, val, Nothing))
This doesn't work when val has space in between the value name
Dim key As String = "SOFTWARE\Intel\PSIS\PSIS_DECODER"
Dim val As String = "Some Key"
MessageBox.Show(Microsoft.Win32.Registry.LocalMachine.GetValue(key, val, Nothing))
Have seen enough Microsoft examples and searched enough forums to find no help. Last attempt here before I look for alternatives
Any magic ?
Additional Information:
Here is a snippet which shows that the script returns nothing if there is a space in key name or value.
Here is a key with space in name
Returns nothing
The problem is related to reading from the 64-bit registry.
As found in Read 64-Bit Registry Values Using VB.Net, the solution which worked for the poster was:
use this Format to Read 64-Bit Registry values :
Dim rk1 As RegistryKey Dim rk2 As RegistryKey rk1 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64) rk2 = rk1.OpenSubKey("HARDWARE\DESCRIPTION\System\BIOS") Dim PID As String = rk2.GetValue("SystemProductName").ToString
More information and solutions can be found here :