Solved

VBS - If registry key exisits then delete it

Posted on 2008-06-13
2
274 Views
Last Modified: 2010-04-21
I need the following in a VBS file that if the key exists then delete it or move on.

Thanks.
' Delete Reg Key
 
 

Set WshShell = WScript.CreateObject("WScript.Shell")

key1 = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\PDRFRAME"

WshShell.RegDelete key1 & "\"

Open in new window

0
Comment
Question by:DMTechGrooup
2 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
Comment Utility
you could just "delete" it, and ignore the error if any occurs due to the fact that it does not exist:
 
Set WshShell = WScript.CreateObject("WScript.Shell")
key1 = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\PDRFRAME"
on error resume next
WshShell.RegDelete key1 & "\"

Open in new window

0
 
LVL 24

Author Closing Comment

by:DMTechGrooup
Comment Utility
Fast and accurate with information.  Thanks.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now