Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to read a registry value whose name is a file path using WshShell.RegRead
    primarykey
    data
    text
    <p>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:</p> <pre> [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 </pre> <p>I am attempting to use the <a href="http://msdn.microsoft.com/en-us/library/x05fawxd(VS.85).aspx" rel="nofollow noreferrer">WshShell.RegRead</a> 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?</p> <p>Here is the code that demonstrates the problem:</p> <pre> 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)); </pre> <p>The error I am seeing is:</p> <pre>WshShell.RegRead: Invalid root in registry key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SharedDlls\C:\Program Files\Common Files\ACME Corp\AcmeUtil.dll" </pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload