?
Solved

Array / Registry Delete

Posted on 2014-03-05
5
Medium Priority
?
243 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
[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
  • 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 2000 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

What is a Denial of Service (DoS)?

A DoS is a malicious attempt to prevent the normal operation of a computer system. You may frequently see the terms 'DDoS' (Distributed Denial of Service) and 'DoS' used interchangeably, but there are some subtle differences.

Question has a verified solution.

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

This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Simple Linear Regression
Introduction to Processes

801 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