Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to delete instances of a program in registry in XP?

Status
Not open for further replies.

wvdba

IS-IT--Management
Jun 3, 2008
465
US
Hi.
i have a situation where i would need to delete items from the registry. is there anyway to use a vbscript or something like that to delete an item from windows registry in win-xp?
like:
specifying a string
locating the registry item that contain the string
delete the registry item
thanks
 
The code below, when saved as a .vbs file will check for the presence of a JRE registry entry and delte it if it exists. If you know your VB then you can alter this accordingly. Credit to someone else on the net for this but we use similar code to remove registry entries for a packaged application after it's been delivered and installed. Hope it helps.

Code:
Const HKEY_LOCAL_MACHINE = &H80000002

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

strKeyPath = "SOFTWARE\JavaSoft\Java Runtime Environment\1.4.2_08"
strValueName = "JavaHome"
objRegistry.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue

If IsNull(strValue) Then
   Wscript.Echo "The registry key does not exist."
Else
   Wscript.Echo "The registry key exists."
   objRegistry.DeleteKey HKEY_LOCAL_MACHINE, strKeyPath

End If



I used to have a handle on life... but it broke. Cpt. Red Bull
 
Gee, I'd be cautious about turning a script loose on the registry. What about just doing a manual search through the registry for the item and picking and choosing which instances to remove.

 
I'd tend to agree with Goomb. Letting a script loose on a live Registry is just asking for trouble.

Unless you are expecting several hundreds of entries, I'd give regedit's search feature a whirl first just to be sure there aren't other entries with similar strings that you may not want to remove.

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech
 
I agree with the last two posts and please Backup your Registry before making any changes.

From Regedit Edit > Export name tour backup file and save.
Now feel safe to make changes.

Sam
 
thanks everybody for the posts.
i will definitely back up the registry before doing anything.
thanks again.
 
I live for VBscript registry editing. But, there is no guarentee the what works on this key is going to work on that key. Furthermore, a software has many fingers in the registry. Removing a single key will likely not fix the issue. Although tedious, you are safest with search function in regedit. At least you'll be able to see the "fingers".


-Geates

"I hope I can chill and see the change - stop the bleed inside and feel again. Cut the chain of lies you've been feeding my veins; I've got nothing to say to you!"
-Infected Mushroom

"I do not offer answers, only considerations."
- Geates's Disclaimer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top