[英]How to deal with spaces in a windows registry path from ASP using RegWrite
I have a problem in that from ASP I need to write to a Windows Registry key the path to which contains spaces. 我有一个问题,从ASP,我需要向Windows注册表项写入包含空格的路径。 The WScript.Shell RegRead is happy enough with my key, but RegWrite doesn't like it.
WScript.Shell RegRead对我的密钥很满意,但是RegWrite不喜欢它。 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". 获取: 注册表项“ HKLM \\ SOFTWARE \\ Data Access Worldwide \\ Visual DataFlex \\ 10.0 \\ WebApp Server \\ Web应用程序\\ 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. 我曾尝试使用“ HKLM”缩写“ HKEY_LOCAL_MACHINE”,多余的引号,波浪号和其他替代空格,但现在我已经不明白了。 :-(
:-(
TIA TIA
Mike 麦克风
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. 如果我尝试使用您的代码,则对于驻留在HKEY_CURRENT_USER中的密钥,它可以正常工作,但是对于HKEY_LOCAL_MACHINE中的密钥,我会收到与您相同的错误。 The actual error however, is ACCESS_DENIED.
但是,实际错误是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. 最简单的方法是从Microsoft下载Process Monitor ,在这里您可以查看每个进程的所有实时注册表活动以及任何错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.