Results 1 to 9 of 9

Thread: More registry help. Kedaman?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2000
    Location
    Sudbury, Ontario, Canada
    Posts
    274
    All I need to do is delete 2 registry keys and add them back to delete any values and subkeys. The problem now (using Kedaman's Registry module) is that if there are subkeys in a key, the parent key doesn't get deleted.

    How can I delete a key that contains subkeys?

    This is what I have so far.
    Code:
        DeleteKey "HKEY_USERS\.Default\Software\Microsoft\Windows\CurrentVersion\Explorer\StreamMRU"
        DeleteKey "HKEY_USERS\.Default\Software\Microsoft\Windows\CurrentVersion\Explorer\Streams"
        
        CreateKey "HKEY_USERS\.Default\Software\Microsoft\Windows\CurrentVersion\Explorer\StreamMRU"
        CreateKey "HKEY_USERS\.Default\Software\Microsoft\Windows\CurrentVersion\Explorer\Streams"
    Thanks in advance,

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Theres two functions, Subkeys and keyvalues, Subkeys returns an array of all subkeys and keyvalues returns all values of a key. You could do something recursive:
    Code:
    DeleteKeyTree(key as string)
    dim n
      For each n in subkeys(key)
        DeleteKeyTree n
      next n
      deletekey key
    end sub
    Haven't tested if it works but it should


    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2000
    Location
    Sudbury, Ontario, Canada
    Posts
    274
    Thanks again.

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2000
    Location
    Sudbury, Ontario, Canada
    Posts
    274
    I get a compile error.

    "ByRef argument type mismatch"

    at
    Code:
    DeleteKeyTree n

  5. #5
    Guest
    Use ByVal in your function.
    Code:
    Function MyFunc(ByVal Arg As Integer)

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2000
    Location
    Sudbury, Ontario, Canada
    Posts
    274
    This works if there are subkeys otherwise I get an error.

    Run-Time error '92':

    For loop not initialized


    Code:
    Private Sub DeleteKeyTree(key As String)
        Dim n
        
        For Each n In SubKeys(key)
            DeleteKey key & "\" & n
        Next n
        DeleteKey key
    End Sub

  7. #7
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221

    Red face oooh

    ok, as i said i haven't tested it, but that should do it dcarlson There's no way to tell if an array is empty in vb so you need to use error handling.

    Private Sub DeleteKeyTree(key As String)
    Dim n,arr() as string
    arr=SubKeys(key)
    on error resume next
    n=ubound(arr)
    if err=0 then
    on error goto 0
    For Each n In arr
    DeleteKey key & "\" & n
    Next n
    end if
    DeleteKey key
    End Sub
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  8. #8
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Well actually it doesn't mean it's a error, the key just doesn't have any subkeys If you want to have your errorhandling left, you could still avoid getting unnessesary loads of for loop not initialized errors:
    Code:
    'replace
        Else
    'with
        Elseif err.number=92 then 'do nothing
        Else
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2000
    Location
    Sudbury, Ontario, Canada
    Posts
    274
    The purpose of this snippet is to delete keys from a Compaq laptop that conflicts with the install IE. So instead of stepping through the deleting of entries for each laptop (which is over 20) they'll run the app and if there's any problems then I'll step them through it.

    Again thanks for all the help.

Posting Permissions

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



Click Here to Expand Forum to Full Width