1

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

Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
Mike Peat
  • 445
  • 1
  • 6
  • 14

1 Answers1

1

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.

Darko Kenda
  • 4,781
  • 1
  • 28
  • 31
  • Carko - thank you! Interesting... but I tried it with "HKEY_LOCAL_MACHINE\SOFTWARE\Vodafone\WwanSdk\Wan\Timeouts\testVal" (no spaces, but a nice deep path in HKLM) and it worked perfectly, which is why I think it is the spaces. I've just tried giving everybody Full Control on HKLM, but no change. :-( – Mike Peat Dec 08 '10 at 01:59
  • Ah ha! Yes, you are right. Looking in Process Monitor the error does indeed appear to be Access Denied. So, explicitly granting "Full Control" to the "Users" Group (just to see what happened) and firing it off again... By the Great Holy Gods of the Internet... it worked! Thank you Carko! You are a star! :-) – Mike Peat Dec 08 '10 at 09:11
  • BTW, rather than the whole group "Users", the crucial "Full Control" permission grant is for the "IUSR_XXXXX..." "Internet Guest Account". – Mike Peat Dec 09 '10 at 13:15