运行此代码时:
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/