Link to home
Start Free TrialLog in
Avatar of snusgubben
snusgubbenFlag for Norway

asked on

Delete multiple registry keys

Hi!

I need a vbs script ready for tomorrow that will do the following:

Delete every Reg_SZ that contain the:

value = 12132C3074A8B034E979964BF0DB4745

in all the subkeys of:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData


Thanks!

Avatar of RobSampson
RobSampson
Flag of Australia image

Hi, you should be able to use the script here:
https://www.experts-exchange.com/questions/26457800/Server-gone-Path-blake-non-existant-keeps-hanging.html

Read the comments at the top of the script for instructions on how to use it.
Set strKeyPath to the path to start the search at, ie:

strKeyPath = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData"

Then, with boolMakeChanges set to False, you will be able to read the log file after the search is complete, and delete each string that was found.

Regards,

Rob.
Avatar of snusgubben

ASKER

Hi Rob!

Are you able to delete the REG_SZ instead of changing the value?

This was a MS CRM server installation that went wrong, and we're unable to uninstalled it cleanly.

MS says delete all the keys that contain GUID "12132C3074A8B034E979964BF0DB4745" under "..\..\Installer\Userdata" with "Search + Delete + F3". We sat 2 hours yesterday doing that, but it looks like there are plenty left :(

We might just reinstall the server with all programs/roles needed, but it would be great to just script the deletion of those keys.

I'd have to modify it to do that, which I might be able to do tonight.....not sure if I'll have time though....

Have you tried running with boolMakeChanges set to false?  This would at least give you a log file, and you would see how many instances there were left.

I'll have a look later if I can.

Regards,

Rob.
I have tried another script I found out there which reported to a text file and there was insane many keys left. That's why I was looking for a script to deleted those keys.

Rob, if you're busy, we'll just scratch the server and start all over on monday. This is not a "live or die" case :)
ASKER CERTIFIED SOLUTION
Avatar of RobSampson
RobSampson
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks Rob!!

I'll give it a shot on monday. I'm aware of the risk :)
Sure, let me know how it goes.

Rob.
The script ran like Usain Bolt on a good day :)

It deleted the keys we wanted to get rid of.

Excelent piece of work Rob!
Great!  I'm sure you held your breath for a while ;-)

Glad it worked though.

Regards,

Rob.
There was a lot of keys reside "..\Installer\Userdata" so it ran for about 5 minutes just displaying keys it read. I started to think it was a loop, but it was just the amount of keys.

Just info if someone google this and don't have the patient to wait for the script to finish :)
Oh yeah, the registry is huge, and to check every key, value name, and value data takes a long time!  That's why I made it show the current position.  Just out of interest, if you open the log file in Excel, and count the lines with DELETED in them....how many were there?

Rob.
It didn't create a log file. It was just output to cmd.

When I changed the bool to "True" (with <DELETE>) it throw an error when it finished. "Object required". I can't remember excactly what object it referred to. I was too eager to see if those keys was deleted.
Oh, I don't know what the error would have been, I haven't actually tested it on a dev machine yet.  However, it should have created a log file in the same folder as the script itself called
Search_Through_Registry_and_SubKeys_To_Change_Value_With_Log_File_Log.txt

if you didn't change the file name.  I would be surprised that the script ran at all if this didn't get created.  If you ran the script from a UNC path, the log might be in the C:\Windows\System32 folder.

Regards,

Rob.
I'll have a look in the morning if I can find the log
The log was created.

Contained 368 keys marked for deletion.
Ha ha, no wonder you wanted a script!  Glad to help, thanks for saving the cat.... (from the death of curiosity)