vbscript - 错误: "Invalid root in registry key" with Shell.RegWrite

标签 vbscript registry

运行此代码时:

CreateObject("WScript.Shell").RegWrite "HKLM\Whatever\", "MyValue", "REG_SZ"

我仅在 Windows 8 上遇到 .RegWrite 问题,出现错误:

"Invalid root in registry key".

最佳答案

好吧,由于错误描述如此无益,我需要做一些测试来找出这是权限问题。但是,提升脚本可以解决此问题。为了做出这个真正的答案,我应该发布我所做的事情,对吗?

Call ElevateUAC

' ---------------------------
' my duty task goes here...
' ---------------------------


Sub ElevateUAC
    If Not WScript.Arguments.Named.Exists("elevated") Then
        'Launch the script again as administrator
        With CreateObject("Shell.Application")
        .ShellExecute "wscript.exe", """" & _
            WScript.ScriptFullName & """ /elevated", "", "runas", 1
            WScript.Quit
        End With
    End If
End Sub

关于vbscript - 错误: "Invalid root in registry key" with Shell.RegWrite,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14763625/

相关文章:

vbscript - 从VBScript函数返回Null还是什么都没有?

vbscript - vbs监控文件夹文件的方法

asp-classic - 没有线索.. 溢出,Microsoft VBScript 运行时错误 '800a0006'

c# - .Net TimeZoneInfo ID - 它是特定于 Windows 语言的吗?

windows-installer - 卸载软件时如何删除 HKCU 注册表项?

c# - 调用 GetSubkeyNames() 后无法访问注册表?

javascript - 单击提交按钮时如何调用 asp 函数?

xml - 使用vbscript读取xml文件

registry - 将值写入 Inno Setup 中存储在数组中的所有注册表项

python - 使用Python的_winreg写入DWORD值?