enumerating and deleting reg function

Author Message
Bushmen

  • Total Posts : 122
  • Scores: 0
  • Reward points : 0
  • Joined: 2/4/2005
  • Location:
  • Status: offline
enumerating and deleting reg function Monday, March 07, 2005 11:46 PM (permalink)
0
hi,

do any of you guys have a function that enumerates all registry keys and values
for a specific registry key,

and then for each key and value, delete them.

i am having trouble deleting a key with other keys and values.

bushmen
Scripting is Fab!!
 
#1
    mbouchard

    • Total Posts : 2110
    • Scores: 29
    • Reward points : 0
    • Joined: 5/15/2003
    • Location: USA
    • Status: offline
    Re: enumerating and deleting reg function Tuesday, March 08, 2005 1:42 AM (permalink)
    0
    Here is a script that we use where I work.

    Const HKEY_CURRENT_USER = &H80000001
    'Delete the users office profile
    Call DeleteRegistryKey(HKEY_CURRENT_USER, "Software\Microsoft\Office")
    
    Sub DeleteRegistryKey(LNGHKEY, strSubkey)
    'Deletes registry key and all subkeys (permissions to delete keys must exist)
    'LNGHKEY: Long value of the root registry key that contains the strSubKey path (can be a constant)
    'strSubkey: Subkey to be deleted (Case-sensitive string)
    'Example: Call DeleteRegistryKey(HKEY_LOCAL_MACHINE, "SOFTWARE\Test\t1")
    Dim reg, aSubkeys, s
    Set reg = GetObject("WinMgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
    reg.EnumKey LNGHKEY, strSubkey, aSubkeys
    If Not IsNull(aSubkeys) Then
    For Each s In aSubkeys
    Call DeleteRegistryKey(LNGHKEY, strSubKey & "\" & s)
    Next
    End If
    ' Error trapping in case we can't delete (no permissions)
    On Error Resume Next
    reg.DeleteKey LNGHKEY, strSubKey
    On Error GoTo 0
    End Sub
    
     
    #2
      Bushmen

      • Total Posts : 122
      • Scores: 0
      • Reward points : 0
      • Joined: 2/4/2005
      • Location:
      • Status: offline
      Re: enumerating and deleting reg function Tuesday, March 08, 2005 2:02 AM (permalink)
      0
      thanks for your quick response mike.

      bushmen
       
      #3

        Online Bookmarks Sharing: Share/Bookmark

        Jump to:

        Current active users

        There are 0 members and 1 guests.

        Icon Legend and Permission

        • New Messages
        • No New Messages
        • Hot Topic w/ New Messages
        • Hot Topic w/o New Messages
        • Locked w/ New Messages
        • Locked w/o New Messages
        • Read Message
        • Post New Thread
        • Reply to message
        • Post New Poll
        • Submit Vote
        • Post reward post
        • Delete my own posts
        • Delete my own threads
        • Rate post

        2000-2012 ASPPlayground.NET Forum Version 3.9