Hi,

I have HKLM\Software\Humm. Humm contains may other subkeys.

Is there a script that will delete Humm and all it's subkeys?

Thanks,

Mike.
0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Community Chosen Answer

4
Hello Mike,

i think the following script should work.
Copy & Past it in Primalscript, You have to change the strkeypath with the key(s) you want to delete, you can also use this to delete only one regkey.

'*******Begin script*********
On Error Resume Next

Const HKEY_LOCAL_MACHINE = &H80000002

strComputer = "."
strKeyPath = "Software\Test"

Set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")

DeleteSubkeys HKEY_LOCAL_MACHINE, strKeypath

Sub DeleteSubkeys(HKEY_LOCAL_MACHINE, strKeyPath)
objRegistry.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubkeys
If IsArray(arrSubkeys) Then
For Each strSubkey In arrSubkeys
DeleteSubkeys HKEY_LOCAL_MACHINE, strKeyPath & "\" & strSubkey
Next
End If
objRegistry.DeleteKey HKEY_LOCAL_MACHINE, strKeyPath
End Sub
'*******End Script*******

Regards,
Rave
Answered 02/09/2007 by: Rave
Senior Yellow Belt

Please log in to comment
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Answers

0
Hi Rave,

Thanks very much - worked a treat!

Cheers, Mike.
Answered 02/12/2007 by: Meic
Second Degree Blue Belt

Please log in to comment
0

For Each strSubkey In arrSubkeys


Thanks Mate... Script did a job for me [;)]
Answered 09/26/2008 by: veday001
Senior Yellow Belt

Please log in to comment
0
'*******Begin script*********
On Error Resume Next

Const HKEY_LOCAL_MACHINE = &H80000002

strComputer = "."
strKeyPath = "Software\Test"

Set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")

DeleteSubkeys HKEY_LOCAL_MACHINE, strKeypath

Sub DeleteSubkeys(HKEY_LOCAL_MACHINE, strKeyPath)
objRegistry.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubkeys
If IsArray(arrSubkeys) Then
For Each strSubkey In arrSubkeys
DeleteSubkeys HKEY_LOCAL_MACHINE, strKeyPath & "\" & strSubkey
Next
End If
objRegistry.DeleteKey HKEY_LOCAL_MACHINE, strKeyPath
End Sub
'*******End Script*******


I need change this script to delete key and subkey from all users (HKCU\Software\Test - Main Registry) in computer.
How can I adapt this script to do it?

Regards
Answered 06/17/2010 by: eddysj
Yellow Belt

Please log in to comment
0
The script isn't particularly well-coded, having HKEY_LOCAL_MACHINE hard-wired into the function. I recommend you download the class pack from JSWare.net which includes a registry class. This has a number of useful functions which you'll find easy to use. However, I appreciate that most people ignore my advice, so: Option Explicit

Dim intHive
Dim strComputer
Dim strKeyPath

Const HKEY_CLASSES_ROOT = &H80000000
Const HKEY_CURRENT_USER = &H80000001
Const HKEY_LOCAL_MACHINE = &H80000002
Const HKEY_USERS = &H80000003
Const HKEY_CURRENT_CONFIG = &H80000005

On Error Resume Next

strComputer = "."
'intHive = HKEY_LOCAL_MACHINE
intHive = HKEY_CURRENT_USER
strKeyPath = "Software\Test"

Set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")

DeleteSubkeys intHive, strKeypath

Set objRegistry = Nothing

Sub DeleteSubkeys(ByVal intRegistryHive, ByVal strRegistryKey)
Dim arrSubkeys

objRegistry.EnumKey intRegistryHive, strRegistryKey, arrSubkeys
If IsArray(arrSubkeys) Then
For Each strSubkey In arrSubkeys
DeleteSubkeys intRegistryHive, strRegistryKey & "\" & strSubkey
Next
End If

objRegistry.DeleteKey intRegistryHive, strRegistryKey
End Sub
Answered 06/18/2010 by: VBScab
Red Belt

Please log in to comment
0
ORIGINAL: VBScab

The script isn't particularly well-coded, having HKEY_LOCAL_MACHINE hard-wired into the function. I recommend you download the class pack from JSWare.net which includes a registry class. This has a number of useful functions which you'll find easy to use. However, I appreciate that most people ignore my advice, so: Option Explicit

Dim intHive
Dim strComputer
Dim strKeyPath

Const HKEY_CLASSES_ROOT = &H80000000
Const HKEY_CURRENT_USER = &H80000001
Const HKEY_LOCAL_MACHINE = &H80000002
Const HKEY_USERS = &H80000003
Const HKEY_CURRENT_CONFIG = &H80000005

On Error Resume Next

strComputer = "."
'intHive = HKEY_LOCAL_MACHINE
intHive = HKEY_CURRENT_USER
strKeyPath = "Software\Test"

Set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")

DeleteSubkeys intHive, strKeypath

Set objRegistry = Nothing

Sub DeleteSubkeys(ByVal intRegistryHive, ByVal strRegistryKey)
Dim arrSubkeys

objRegistry.EnumKey intRegistryHive, strRegistryKey, arrSubkeys
If IsArray(arrSubkeys) Then
For Each strSubkey In arrSubkeys
DeleteSubkeys intRegistryHive, strRegistryKey & "\" & strSubkey
Next
End If

objRegistry.DeleteKey intRegistryHive, strRegistryKey
End Sub



No, this script delete key just to user logged. I need delete the key to others users too. For exemple, I'm logged with User01 and when I execute the script, I want delete the key in Current User to User01, User02, User03.

Regards
Answered 06/18/2010 by: eddysj
Yellow Belt

Please log in to comment
0
Then you have to get into the mire of using REG.EXE to load the user's hive [shudder]....

Why not run the script as an Active Setup job?
Answered 06/18/2010 by: VBScab
Red Belt

Please log in to comment
0
Hi All,

I have a similar requirement as edd has.

I have captured a setup to an msi, this application has a file association which is present already in OS. So when i unistall the app th file association will dissappear. So i have added that association in HKCU\Software\Classes. But this will restore the association only for administrator(from where the application is uninstalled).

So I wanted to use a vbscript while uninstalling the app which will search all users HKCU\Software\Classes and will delete it for every user. I hope this is the best method to achieve this. Please also let me know if there is any other way.

I have googled for the script but no success. Thanks for your help.
Answered 05/19/2011 by: naveen.packager
Green Belt

Please log in to comment
0
P R E T T Y much like my post above yours intimates, Active Setup is the best way to propogate (or remove) logged-in user data when a package has no advertised entry-points.
Answered 05/19/2011 by: VBScab
Red Belt

Please log in to comment
0
Thanks VBScab. I want to achieve this during uninstallation. During installation i can use the sript file to be kept in installation folder and use active setup. But during uninstallation i need to clean all the files and folders related to the application. So i thought using vbscript would be the better way. Waiting for your advice.

Thanks once again.
Answered 05/19/2011 by: naveen.packager
Green Belt

Please log in to comment
0
So:

- Create a new component
- Create a new GUID (use a blank Wise project as a cheat, if you don't have a GUID-generating script/tool)
- In your new component, create a new Active Setup key in HKLM and set the stub path to run your deletion script/batch file.
- Condition the component to be "installed" only during uninstallation

Next!
Answered 05/19/2011 by: VBScab
Red Belt

Please log in to comment
0
Next!

see, now if only we weren't all sharing our knowledge for free out of the goodness of our heart you could have added

$$ KaChinggg $$ !!

but no... [:D]

PJ
Answered 05/19/2011 by: pjgeutjens
Red Belt

Please log in to comment
0

Next!


Here it goes.........[:D]

I have tried conditioning the component using REMOVE~="ALL" and also MaintenanceMode="Remove". But the component is not getting installed during uninstalltion. I am using wps 7.

Please let me know if i am missing anything.

Thanks.
Answered 05/20/2011 by: naveen.packager
Green Belt

Please log in to comment
0
Thanks Rave for that code snippet - i've been looking for something like this for a while now! [:D]
Answered 06/22/2011 by: avinalaff
Yellow Belt

Please log in to comment
Answer this question or Comment on this question for clarity