|
-
Dec 4th, 2000, 02:39 PM
#1
Thread Starter
Hyperactive Member
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,
-
Dec 4th, 2000, 04:04 PM
#2
transcendental analytic
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.
-
Dec 4th, 2000, 04:19 PM
#3
Thread Starter
Hyperactive Member
-
Dec 4th, 2000, 04:39 PM
#4
Thread Starter
Hyperactive Member
I get a compile error.
"ByRef argument type mismatch"
at
-
Dec 4th, 2000, 04:47 PM
#5
Use ByVal in your function.
Code:
Function MyFunc(ByVal Arg As Integer)
-
Dec 4th, 2000, 04:57 PM
#6
Thread Starter
Hyperactive Member
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
-
Dec 4th, 2000, 05:09 PM
#7
transcendental analytic
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.
-
Dec 5th, 2000, 01:02 PM
#8
transcendental analytic
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.
-
Dec 5th, 2000, 01:14 PM
#9
Thread Starter
Hyperactive Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|