Question

I'm reading some registries in ASP Classic to get some values I need and saving them as application level variables. In the global.asa file I have the code:

<SCRIPT LANGUAGE=VBScript RUNAT=Server>
Sub Application_OnStart
    Application("test") = "testing..."
    Dim WSHShell, regLink
    Set WSHShell = CreateObject("WScript.Shell")
    regLink = "HKEY_LOCAL_MACHINE\SOFTWARE\Odyssey\"

    Application("test2") = WSHShell.RegRead(regLink & "value")
End Sub
</SCRIPT>

In my test.asp file, I simply output the "test" and "test2" variables. However, on running test.asp, I get the error message:
WshShell.RegRead error '80070002'
Invalid root in registry key

I have checked and double checked that the key indeed exists, and this code worked on our old server, so I think it is a configuration issue in IIS. I'll be damned if I can find it though. ASP Classic is installed and enabled, and I'm using IIS 7.5 on Windows Server 2008 R2 x64. Hopefully someone has an idea of what the problem is.

EDIT: I downloaded Process Monitor to look at the registry access. After some searching. I found that it is actually looking for the key in "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Odyssey\value". I gather this has to do with the server being 64x. I don't want to move the keys to that location, as they will likely never be found again, especially when the code points to a different directory.

Is there a way to stop this redirection or change the structure so this can work?

Thanks in advance for your help.

Doug

Was it helpful?

Solution

As mentioned in the edit to my question, the problem appears to be that the URL was being redirected because it was a x64 system. I ended up moving the registries I was trying to access to HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Odyssey. I then modified the code slightly to look for the keys in that location specifically.

regLink = "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Odyssey\"

Since I specified the Wow6432Node myself, the system won't add another one in. I would've rather kept the keys in their previous location, but at least the code points to where they are. As it was previously, someone looking at the code would never have guessed to look in the Wow6432Node directory. The important part is that the keys will not be lost to the depths of the Windows registry system.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top