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)
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
|
|
|
|
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)
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
|
|
|
|
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)
thanks for your quick response mike. bushmen
|
|
|
|