Start Up Program - Remove (VB.NET)

This is a continuation of my other tutorial in vb.net that loads and displays the number of startup programs in your computer and then displays it. Now, this tutorial aims to select and remove the retrieved start up programs in our pc. strong>Now, let's start this tutorial! 1. Let's start with creating a Windows Form Application for this tutorial by following the following steps in Microsoft Visual Studio: Go to File, click New Project, and choose Windows Application. 2. Next, add one ListView with two columns, one button that loads the startup programs and another button that removes the startup program, and one label that will be display the number of startup programs. You must design your interface like this: output 3. Now, we will do the coding. First, we will import the Microsoft.Win32 library to access the registry key namespace.
  1. Imports Microsoft.Win32
Now, declare some of the variables that we will going to use for loading the number of startup programs and display it on the label.
  1. Dim g As RegistryKey
  2. Dim appname As String
  3. Dim newlistv As New ListView
  4. Dim a As String, m, u, Numberofstartupprograms As Int32
Copy this code below to load the number of startup programs. This was the last tutorial that I have created with loading the startup.
  1. Private Sub ButtonLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonLoad.Click
  2.  
  3. 'clear the listview and the newlistview
  4. Numberofstartupprograms = 0
  5. ListView1.Items.Clear()
  6. newlistv.Items.Clear()
  7.  
  8. ' accessing the local machine of the registy
  9. g = Registry.LocalMachine.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Run", True)
  10.  
  11. ' get all the startup programs
  12. For Each item In g.GetValueNames
  13. Numberofstartupprograms += 1
  14. 'get the path of the name
  15. appname = CStr(g.GetValue(item))
  16. Application.DoEvents()
  17.  
  18. ' added the startup programs to the listview
  19. ListView1.Items.Add(appname).SubItems.Add(item)
  20. newlistv.Items.Add(item)
  21.  
  22. 'retrieved the total number of programs on the label
  23. Label1.Text = "Total Start-up: " & Numberofstartupprograms
  24. Next
  25. End Sub
Lastly, for our main code in removing the selected start up programs, we will declare first this variables.
  1. Dim value As String, number As Int32
Now, to remove the selected startup programs, have this code below:
  1. Private Sub ButtonRemove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonRemove.Click
  2. If Not ListView1.SelectedItems.Count = 0 Then
  3. number = ListView1.SelectedItems(0).Index
  4. g.DeleteValue(newlistv.Items(number).Text)
  5. MsgBox(ListView1.SelectedItems(0).Text & " was succesfully deleted", MsgBoxStyle.Information)
  6. ListView1.Items.RemoveAt(number)
  7. End If
  8. End Sub

Output:

output Download the code and try it. For more inquiries and need programmer for your thesis systems in any kind of programming languages, just contact my number below. Best Regards, Engr. Lyndon Bermoy IT Instructor/System Developer/Android Developer/Freelance Programmer Mobile: 09488225971 Landline: 826-9296 E-mail:[email protected] Add and Follow me on Facebook: https://www.facebook.com/donzzsky Visit and like my page on Facebook at: https://www.facebook.com/BermzISware

Add new comment