VBscript,写入注册表

时间:2012-03-30 15:21:09

标签: windows vbscript registry

我无法修改注册表项值

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.RegWrite "HKCU\MyNewKey\MyValue", "0"
WshShell.RegWrite "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\EnableLUA","0"

当我执行代码时,它总是出错,“注册表中的根目录无效” 什么错误的代码可以有人解释这个?

2 个答案:

答案 0 :(得分:2)

尝试使用“HKEY_LOCAL_MACHINE”代替HKLM。 “HKEY_CURRENT_USER”代替HKCU ......

答案 1 :(得分:0)

关于 vbs 中的 registery write 有三个参数。欲了解更多信息,请前往 https://www.vbsedit.com/html/678e6992-ddc4-4333-a78c-6415c9ebcc77.asp

问题是您没有提到寄存器的大小,即 REG_SZ、DWORD、QWORD 等

CreateObject("WScript.Shell").RegWrite "HKCU\Software\Microsoft\NewRegisteryWrite", "MyString", "REG_SZ"