Jump to content

Recommended Posts

Posted

Is there a special way to remove a reg key from classes root? I have a script that works fine when removing keys from HKLM but it fails to delete a key in HKCR. The first two entries are deleted every time but the third errors saying 'Unable to remove registry key' 80070002. I can remove the key using regedit so it's not being held open.

 

On Error Resume Next

Dim WshShell, bKey
Set WshShell = WScript.CreateObject("WScript.Shell")

WshShell.RegDelete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\IgfxTray"
WshShell.RegDelete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\HotKeysCmds"
WshShell.RegDelete "HKCR\Directory\Background\shellex\ContextMenuHandlers\igfxcui"


set WSHSHell = Nothing

wscript.quit

 

Thanks.

Posted

Try:

 

WshShell.RegDelete "HKLM\software\classes\Directory\Background\shellex\ContextMenuHandlers\igfxcui"

 

but I think HKCR should work (HKCR is just an alias to the "real" location)

 

Error 0x80070002 means "not found" so are you sure of the spelling??

Posted (edited)

Sorted it, I needed a trailing slash at the end to delete subkeys.

 

WshShell.RegDelete "HKCR\Directory\Background\shellex\ContextMenuHandlers\igfxcui\"

Edited by cookie_monster

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...