Solved

Array / Registry Delete

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
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 …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

910 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

22 Experts available now in Live!

Get 1:1 Help Now