开发者

Can't delete registry key using VBS

I am trying to delete a registry key. Here is my code:

Option Explicit
Dim objShell
Set objShell = WScript.CreateObject( "WScript.Shell" )  
Dim strDelete
strDelete = objShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\test\")
WScript.echo(strDelete)
objShell.RegDelete "HKEY_LOCAL_MACHINE\SOFTWARE\test\"
WScript.Quit

When I run this, I get this output:

Microsoft (R) Windows Script Host Version 5.8

Copyright (C) Microsoft Corporation. All rights reserved.

test

N:\RogueDevelopment\test.vbs(23, 1) WshShell.RegDele开发者_高级运维te: Invalid root in registry key "HKEY_LOCAL_MACHINE\SOFTWARE\test\".

My registry key is located at "HKEY_LOCAL_MACHINE\SOFTWARE\test\" and it has a default value of "test". The value in the key is being read correctly, but the key cannot be deleted. I am running this script on Windows 7. Why is this happening?


You don't have permission to open HKEY_LOCAL_MACHINE\SOFTWARE\test\ for delete access. If you really need to modify keys under HKLM, you will need to elevate your process.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜