Solved

Array / Registry Delete

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

This is about my first experience with programming Arduino.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
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 …

816 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

11 Experts available now in Live!

Get 1:1 Help Now