Solved

Array / Registry Delete

Posted on 2014-03-05
5
228 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 27

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
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 …

760 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

18 Experts available now in Live!

Get 1:1 Help Now