+ Post New Thread
Results 1 to 2 of 2
Scripts Thread, VB Delete registry keys with sub keys in Coding and Web Development; I've been using a kix script to do this for ages (Delete registry keys with sub keys) that I couldn't ...
  1. #1
    cookie_monster's Avatar
    Join Date
    May 2007
    Location
    Derbyshire
    Posts
    4,221
    Thank Post
    395
    Thanked 278 Times in 239 Posts
    Rep Power
    75

    VB Delete registry keys with sub keys

    I've been using a kix script to do this for ages (Delete registry keys with sub keys) that I couldn't do with a VB script then today I came accross a technet tutorial and I think I'm there. This might of already been posted but it didn't come up in a search.

    Hey, Scripting Guy!: How Can I Delete a Key and its Subkeys from the Registry?

    EDIT

    I just need to work out how to point it to this key "HKEY_CURRENT_USER\Software\Microsoft\Windows\Curr entVersion\Explorer\MenuOrder" then I'm there.

    (Scratches head)
    Last edited by cookie_monster; 6th November 2009 at 09:45 AM.

  2. Thanks to cookie_monster from:

    mac_shinobi (6th November 2009)

  3. #2
    cookie_monster's Avatar
    Join Date
    May 2007
    Location
    Derbyshire
    Posts
    4,221
    Thank Post
    395
    Thanked 278 Times in 239 Posts
    Rep Power
    75
    Right it's sorted now to put it into my real script

    Code:
    On Error Resume Next 
    
    Const HKEY_CURRENT_USER = &H80000001 
    
    strComputer = "."
    strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Explorer\MenuOrder" 
    
    Set objRegistry = GetObject("winmgmts:\\" & _
        strComputer & "\root\default:StdRegProv") 
    
    DeleteSubkeys HKEY_CURRENT_USER, strKeypath 
    
    Sub DeleteSubkeys(HKEY_CURRENT_USER, strKeyPath) 
        objRegistry.EnumKey HKEY_CURRENT_USER, strKeyPath, arrSubkeys 
    
        If IsArray(arrSubkeys) Then 
            For Each strSubkey In arrSubkeys 
                DeleteSubkeys HKEY_CURRENT_USER, strKeyPath & "\" & strSubkey 
            Next 
        End If 
    
        objRegistry.DeleteKey HKEY_CURRENT_USER, strKeyPath 
    End Sub

    Some excellent extra info here on using WMI and VB to modify the registry.

    http://blogs.technet.com/heyscriptin...out-value.aspx



SHARE:
+ Post New Thread

Similar Threads

  1. Lapcabby Keys
    By Little-Miss in forum General Chat
    Replies: 9
    Last Post: 11th September 2009, 02:35 PM
  2. MS Keys online
    By gibboap in forum General Chat
    Replies: 2
    Last Post: 29th May 2009, 02:36 PM
  3. Replies: 9
    Last Post: 10th February 2009, 03:46 AM
  4. Blue Keys?
    By wesleyw in forum How do you do....it?
    Replies: 4
    Last Post: 18th December 2008, 01:07 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
  •