Question

I have a problem in that from ASP I need to write to a Windows Registry key the path to which contains spaces. The WScript.Shell RegRead is happy enough with my key, but RegWrite doesn't like it. I have tested using other (dummy) paths and it really looks like it is the spaces that are causing the problem.

<%
   Dim WSH, disable
   Set WSH = CreateObject("WScript.Shell")
   disable = Request("disable")  ' disable will be 1 or 0
   key = "HKEY_LOCAL_MACHINE\SOFTWARE\Data Access Worldwide\" & _
         "Visual DataFlex\10.0\WebApp Server\Web Applications\" & _
         "DAW.Examples.Order10\Disable"
   WSH.RegWrite key, CInt( disable ), "REG_DWORD" 
%>

Gets: Invalid root in registry key "HKLM\SOFTWARE\Data Access Worldwide\Visual DataFlex\10.0\WebApp Server\Web Applications\DAW.Examples.Order10\Disable".

Anybody know what to do to fix the problem? How to escape the spaces maybe?

I've tried using the "HKLM" abbreviation for "HKEY_LOCAL_MACHINE", extra quotes, tildes and other substitutions for the spaces, but now I'm out of ideas. :-(

TIA

Mike

Was it helpful?

Solution

I don't think the problem are spaces, but more probably permissions.

If I try your code, it works fine for keys residing in HKEY_CURRENT_USER, but I get the same error as you for keys in HKEY_LOCAL_MACHINE. The actual error however, is ACCESS_DENIED.

The easiest way is if you download Process Monitor from Microsoft, where you can see all real-time registry activity for each process along with any errors.

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