?
Solved

VBS - If registry key exisits then delete it

Posted on 2008-06-13
2
Medium Priority
?
282 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 21783113
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
ID: 31467099
Fast and accurate with information.  Thanks.
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
Suggested Courses

719 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