Solved

Array / Registry Delete

Posted on 2014-03-05
5
237 Views
Last Modified: 2014-03-06
Hi I am trying to delete some know registry problems on my computer as apart of a test program I'm working on. I have the follow but can't get it to work correctly, the values exist in the Registry however I can't seem to get it to loop and delete them correctly.

Please help with code or code clean up that leads to an working state.

Dim reginfo(5) As String
        reginfo(0) = "SOFTWARE\ClASSES\AppGraffiti.AppGraffitiJS"
        reginfo(1) = "SOFTWARE\CLASSES\WOW6432NODE\CLSID\{02478D38-C3F9-4EFB-9B51-7695ECA05670}"
        reginfo(2) = "SOFTWARE\CLASSES\WOW6432NODE\CLSID\{058F0E48-61CA-4964-9FBA-1978A1BB060D}"
        reginfo(3) = "SOFTWARE\CLASSES\WOW6432NODE\CLSID\{1241CEBD-9777-4BC6-AAE5-2A77E25DB246}"
        reginfo(4) = "SOFTWARE\CLASSES\WOW6432NODE\CLSID\{13119113-0854-469D-807A-171568457991}"
        reginfo(5) = "SOFTWARE\CLASSES\WOW6432NODE\CLSID\{173A5778-34BF-48A2-8A5E-6963CE922FED}"

        For regdata = LBound(reginfo) To UBound(reginfo)

            If My.Computer.Registry.LocalMachine.GetValue(reginfo(regdata), Nothing, Nothing) Is Nothing Then
                MsgBox(reginfo(regdata) & " - Not Found")
            Else
                MsgBox(reginfo(regdata) & " - Found")
            End If

        Next

Open in new window

0
Comment
Question by:-Geek
  • 4
5 Comments
 
LVL 1

Author Comment

by:-Geek
ID: 39908416
The goal is to find the match and remove it from the registry.
0
 
LVL 28

Accepted Solution

by:
Ark earned 500 total points
ID: 39908699
Seems your array contains SUBKEYS, not values, so
     For regdata = LBound(reginfo) To UBound(reginfo)
            Dim subkey = My.Computer.Registry.LocalMachine.OpenSubKey(reginfo(regdata))
            If subkey Is Nothing Then
                MsgBox(reginfo(regdata) & " - Not Found")
            Else
                MsgBox(reginfo(regdata) & " - Found")
                subkey.Close()
                'My.Computer.Registry.LocalMachine.DeleteSubKeyTree(reginfo(regdata), False)
            End If
        Next

Open in new window

Actually you can just use
For regdata = LBound(reginfo) To UBound(reginfo)
             My.Computer.Registry.LocalMachine.DeleteSubKeyTree(reginfo(regdata), False)
        Next

Open in new window

The second parameter of DeleteSubkeyTree (which is False) means that method just skip  non-existing key without exception
0
 
LVL 1

Author Comment

by:-Geek
ID: 39908842
Thank you for the reply,

when I did a test run I looked in regedit and found

"HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432NODE\CONDUIT"

however when I run to remove it, it will not find it. Any idea?
0
 
LVL 1

Author Comment

by:-Geek
ID: 39908868
I think it was the leading \ got it all sorted thank you.
0
 
LVL 1

Author Closing Comment

by:-Geek
ID: 39908869
worked perfect thank you
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to duplicate form in Visual Studio 2015 2 57
VS 2017 18 35
Adding items to a C# list incrementally 5 29
Access Schema 6 24
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

839 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