+ Post New Thread
Results 1 to 3 of 3
Scripts Thread, Delete HKCR key in Coding and Web Development; Is there a special way to remove a reg key from classes root? I have a script that works fine ...
  1. #1
    cookie_monster's Avatar
    Join Date
    May 2007
    Location
    Derbyshire
    Posts
    4,217
    Thank Post
    394
    Thanked 278 Times in 239 Posts
    Rep Power
    75

    Delete HKCR key

    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.

    Code:
    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.

  2. #2

    Join Date
    Aug 2005
    Location
    London
    Posts
    3,157
    Thank Post
    116
    Thanked 529 Times in 452 Posts
    Blog Entries
    2
    Rep Power
    124
    Try:

    Code:
    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??

  3. #3
    cookie_monster's Avatar
    Join Date
    May 2007
    Location
    Derbyshire
    Posts
    4,217
    Thank Post
    394
    Thanked 278 Times in 239 Posts
    Rep Power
    75
    Sorted it, I needed a trailing slash at the end to delete subkeys.

    Code:
    WshShell.RegDelete "HKCR\Directory\Background\shellex\ContextMenuHandlers\igfxcui\"
    Last edited by cookie_monster; 4th March 2010 at 03:32 PM.

SHARE:
+ Post New Thread

Similar Threads

  1. Replies: 3
    Last Post: 26th April 2010, 02:13 PM
  2. RM One Allen Key
    By bladedanny in forum Hardware
    Replies: 4
    Last Post: 15th May 2009, 04:30 PM
  3. logoff script to delete registry key
    By ICMC in forum Scripts
    Replies: 3
    Last Post: 26th January 2009, 10:37 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •