I am writing some javascript to be executed by the Windows Scripting Host, and I need to be able to read the shared file counts from the registry for certain specific DLLs. The registry key and values look like this:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SharedDlls] "C:\\Program Files\\Common Files\\ACME Corp\\AcmeUtil.dll"=dword:00000002 "C:\\Program Files\\Common Files\\ACME Corp\\SuperEdit.ocx"=dword:00000001
I am attempting to use the WshShell.RegRead method to do this, but it doesn't seem to work. I think the problem is that this method only takes a single parameter which is the concatenated key path and value name for the value to be retrieved. Since the value name in this case is itself a path, the method thinks it is part of the key. Is there any way to get this method to recognize the value name for what it is?
Here is the code that demonstrates the problem:
var shell = WScript.CreateObject("WScript.Shell"); var keyPath = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\SharedDlls\\"; var valName = "C:\\Program Files\\Common Files\\ACME Corp\\AcmeUtil.dll"; WScript.Echo("count = " + shell.RegRead(keyPath + valName));
The error I am seeing is:
WshShell.RegRead: Invalid root in registry key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SharedDlls\C:\Program Files\Common Files\ACME Corp\AcmeUtil.dll"