pghtech 0 Newbie Poster

I will start off by saying that I am a true beginer with VB so please forgive me if any of my issues are simple or if my terminology is incorrect;

I am trying to creat a program to automate many of the things I do when I build a computer. I was attempting to do this via batch files but got stuck when I needed to search the registry for cetain keys and delete the parrent folder in which it resides in.

For instance: Installing a MS Loop Back Adapter
I found a utility that works at the command promt called DEVCON that will allow me to install a MS Loop Back Adapter. I was doing this through a batch file but found that I can call the utility through VB and get the same result (of course I still need to have the DEVCON.exe)

If InstallMSLoopBack_CheckBox.CheckState = CheckState.Checked Then

            MSLoopBack = "C:\0_systemsetup\devcon install %WINDIR%\Inf\Netloop.inf *MSLOOP"

            Shell("cmd /c " & MSLoopBack, vbHide)
End If

End Sub

The problem I run into is when I got to rename the MS Loop Back Adapter the only way I was doing it through the batch file was if I know what the adaptor is going to be named (i.e. "Local Area Connection 2") Again i was using another command line utility REGFIND

REGFIND -P HKEY_LOCAL_MACHINE\SYSTEM\CURRENTCONTROLSET\CONTROL\NETWORK\ "Local Area Connection 2" -r "MSLOOPBACK"


The Adaptor Name will be "Local Area Connection 2" 90% of the time but I know there has to be a way for me to search the registry and replace the vaule. After I started looking through the registry on one the computers I work on alot and am constantly ghosting new images on, I noticed that there were mainy entrys in the registry for adapters that aren't in use. So I know want to start off by searching the registry for ANY MS Loop Back Adaptors and remove them before I install the first one just to keep thing clean.
I was trying to search for items that I knew were common values to MS Loop Back Adapters
and them search for the connection name "Local Area Connection" and if both search results are true the remove them, but I don't want to just remove the registry keys, but the parent folder it resides in. I was attempting to do this and just display the value in a message box before i started deleting things from the registry, but I got errors when I tried to combined the two results

Private Sub Run_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Run_Button.Click
        Dim regvalue As String
        Dim localA As String
     
        If My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}\", "PnpInstanceID", "ROOT\\NET\\000") Is "ROOT\\NET\\000" Then
            regvalue = "ROOT\\NET\\000"
            
            If My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}\", "Name", "Local Area Connection") Is "Local Area Connection" Then
                localA = "Local Area Connection"

                If (localA = "Local Area Connection") & (regvalue = "ROOT\\NET\\000") Then
                    MsgBox("MS Loop Back")
                End If
            End If
        End If
End Sub

My next task is similar that once I Install and rename the adapter, I want to remove the Notification Icon that is displayed on the task bar, I did notice that there is a "Show Icon" value in same folder in the registry that the adapter is located, but I haven't tried anything with that yet.

My final task with the MS Loop back adapter is to remove all of the protocol bindings with the exception of TCP/IP and move the order of the adaptor order. I was able to do this with a command line utility called NVSPBIND, I have not incorperated this into the VB project yet but this is what the command line entry looks like, and yes requires the NVSPBIND.exe

REM Remove MSLOOP BACK ADAPTOR Network Bindings
cd\
f:
cd \0_systemsetup

rem ================================================================
rem = Removes File and Print Sharing for Microsoft Networks =
rem ================================================================
nvspbind -d msloopback ms_server


rem ================================================================
rem = Removes Client for Microsoft Networks =
rem ================================================================
nvspbind -d msloopback ms_msclient


rem ================================================================
rem = Removes PortVision Plus Protocol Driver =
rem ================================================================
nvspbind -d msloopback ms_pvdrv


rem ================================================================
rem = Removes RpshSi Ndis Protocol =
rem ================================================================
nvspbind -d msloopback rpshsi_proto


rem ================================================================
rem = Removes NSLink Ndis Protocol =
rem ================================================================
nvspbind -d msloopback nslink_proto


rem ================================================================
rem = Moves MSLOOPBACK down in TCP/IP order =
rem ================================================================
nvspbind /-- msloopback ms_tcpip


exit

I would appriciate any help or direction anyone has to offer, and please let me know if I'm way off track.