VB Net - Startup Remover
Create:
1) Listbox - ListBox1
2) Context Menu - ContextMenuStrip1
Two items - View Info, ToolStripMenuItem1 and Delete, DeleteToolStripMenuItem
Code:
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
For Each file As String In My.Computer.FileSystem.GetFiles(My.Computer.FileSystem.SpecialDirectories.Programs & “\Startup”)
If My.Computer.FileSystem.GetFileInfo(file).Extension = “.lnk” Then
Dim name As String = My.Computer.FileSystem.GetName(file)
name = name.Remove(name.Length - 4, 4)
ListBox1.Items.Add(”User\” & name)
End If
Next
Dim path As String = “C:\Documents and Settings\All Users\Start Menu\Programs\Startup”
For Each file As String In My.Computer.FileSystem.GetFiles(path)
If My.Computer.FileSystem.GetFileInfo(file).Extension = “.lnk” Then
Dim name As String = My.Computer.FileSystem.GetName(file)
name = name.Remove(name.Length - 4, 4)
ListBox1.Items.Add(”All Users\” & name)
End If
Next
Dim Reg As Microsoft.Win32.RegistryKey
Reg = My.Computer.Registry.CurrentUser.OpenSubKey(”Software\Microsoft\Windows\CurrentVersion\Run”, True)
For Each nod As String In Reg.GetValueNames
ListBox1.Items.Add(”Current\” & nod)
Next
Dim Reg2 As Microsoft.Win32.RegistryKey
Reg2 = My.Computer.Registry.LocalMachine.OpenSubKey(”Software\Microsoft\Windows\CurrentVersion\Run”, True)
For Each nod As String In Reg2.GetValueNames
ListBox1.Items.Add(”Machine\” & nod)
Next
End Sub
Private Sub DeleteToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DeleteToolStripMenuItem.Click
If Mid(ListBox1.SelectedItem, 1, 2) = “Cu” Then
Dim Reg
Reg = My.Computer.Registry.CurrentUser.OpenSubKey(”Software\Microsoft\Windows\CurrentVersion\Run”, True).GetValue(ListBox1.SelectedItem.ToString.Remove(0, 8))
If MessageBox.Show(”Are you sure you want to delete: ” & vbNewLine & ” ” & “HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run\” & ListBox1.SelectedItem.ToString.Remove(0,
& vbNewLine & ” ” & Reg, “Confirm Delete”, MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
Try
My.Computer.Registry.CurrentUser.OpenSubKey(”Software\Microsoft\Windows\CurrentVersion\Run”, True).DeleteValue(ListBox1.SelectedItem.ToString.Remove(0, 8))
MessageBox.Show(”Deleted ” & My.Computer.Registry.CurrentUser.OpenSubKey(”Software\Microsoft\Windows\CurrentVersion\Run”, True).GetValue(ListBox1.SelectedItem.ToString.Remove(0, 8)) & ” successfully”, “Done!”, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Catch ex As Exception
MessageBox.Show(”Error deleting!”, “Error”, MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End If
ElseIf Mid(ListBox1.SelectedItem, 1, 2) = “Ma” Then
Dim Reg
Reg = My.Computer.Registry.LocalMachine.OpenSubKey(”Software\Microsoft\Windows\CurrentVersion\Run”, True).GetValue(ListBox1.SelectedItem.ToString.Remove(0, 8))
If MessageBox.Show(”Are you sure you want to delete: ” & vbNewLine & ” ” & “HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run\” & ListBox1.SelectedItem.ToString.Remove(0,
& vbNewLine & ” ” & Reg, “Confirm Delete”, MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
Try
My.Computer.Registry.LocalMachine.OpenSubKey(”Software\Microsoft\Windows\CurrentVersion\Run”, True).DeleteValue(ListBox1.SelectedItem.ToString.Remove(0, 8))
MessageBox.Show(”Deleted ” & My.Computer.Registry.LocalMachine.OpenSubKey(”Software\Microsoft\Windows\CurrentVersion\Run”, True).GetValue(ListBox1.SelectedItem.ToString.Remove(0, 8)) & ” successfully”, “Done!”, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Catch ex As Exception
MessageBox.Show(”Error deleting!”, “Error”, MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End If
ElseIf Mid(ListBox1.SelectedItem, 1, 2) = “Us” Then
Dim name As String = ListBox1.SelectedItem.ToString.Remove(0, 4) & “.lnk”
name = My.Computer.FileSystem.SpecialDirectories.Programs & “\Startup” & name
If MessageBox.Show(”Are you sure you want to delete: ” & vbNewLine & ” ” & name, “Confirm Delete”, MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
Try
My.Computer.FileSystem.DeleteFile(name)
MessageBox.Show(”Deleted ” & name & ” successfully”, “Done!”, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Catch ex As Exception
MessageBox.Show(”Error deleting!”, “Error”, MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End If
ElseIf Mid(ListBox1.SelectedItem, 1, 2) = “Al” Then
Dim name As String = ListBox1.SelectedItem.ToString.Remove(0, 9) & “.lnk”
name = “C:\Documents and Settings\All Users\Start Menu\Programs\Startup” & name
If MessageBox.Show(”Are you sure you want to delete: ” & vbNewLine & ” ” & name, “Confirm Delete”, MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
Try
My.Computer.FileSystem.DeleteFile(name)
MessageBox.Show(”Deleted ” & name & ” successfully”, “Done!”, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Catch ex As Exception
MessageBox.Show(”Error deleting!”, “Error”, MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End If
End If
ListBox1.Items.Clear()
For Each file As String In My.Computer.FileSystem.GetFiles(My.Computer.FileSystem.SpecialDirectories.Programs & “\Startup”)
If My.Computer.FileSystem.GetFileInfo(file).Extension = “.lnk” Then
Dim name As String = My.Computer.FileSystem.GetName(file)
name = name.Remove(name.Length - 4, 4)
ListBox1.Items.Add(”User\” & name)
End If
Next
Dim path As String = “C:\Documents and Settings\All Users\Start Menu\Programs\Startup”
For Each file As String In My.Computer.FileSystem.GetFiles(path)
If My.Computer.FileSystem.GetFileInfo(file).Extension = “.lnk” Then
Dim name As String = My.Computer.FileSystem.GetName(file)
name = name.Remove(name.Length - 4, 4)
ListBox1.Items.Add(”All Users\” & name)
End If
Next
Dim Reg1 As Microsoft.Win32.RegistryKey
Reg1 = My.Computer.Registry.CurrentUser.OpenSubKey(”Software\Microsoft\Windows\CurrentVersion\Run”, True)
For Each nod As String In Reg1.GetValueNames
ListBox1.Items.Add(”Current\” & nod)
Next
Dim Reg2 As Microsoft.Win32.RegistryKey
Reg2 = My.Computer.Registry.LocalMachine.OpenSubKey(”Software\Microsoft\Windows\CurrentVersion\Run”, True)
For Each nod As String In Reg2.GetValueNames
ListBox1.Items.Add(”Machine\” & nod)
Next
End Sub
Private Sub ContextMenuStrip1_Opening(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles ContextMenuStrip1.Opening
If ListBox1.SelectedIndex > -1 Then
DeleteToolStripMenuItem.Enabled = True
ToolStripMenuItem1.Enabled = True
Else
DeleteToolStripMenuItem.Enabled = False
ToolStripMenuItem1.Enabled = False
End If
End Sub
Private Sub ToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem1.Click
If Mid(ListBox1.SelectedItem, 1, 2) = “Cu” Then
Dim Reg
Reg = My.Computer.Registry.CurrentUser.OpenSubKey(”Software\Microsoft\Windows\CurrentVersion\Run”, True).GetValue(ListBox1.SelectedItem.ToString.Remove(0, 8))
MessageBox.Show(”Registry Key Information: ” & vbNewLine & ” ” & “HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run\” & ListBox1.SelectedItem.ToString.Remove(0,
& vbNewLine & ” ” & Reg, “Startup Key”, MessageBoxButtons.OK, MessageBoxIcon.Information)
ElseIf Mid(ListBox1.SelectedItem, 1, 2) = “Ma” Then
Dim Reg
Reg = My.Computer.Registry.LocalMachine.OpenSubKey(”Software\Microsoft\Windows\CurrentVersion\Run”, True).GetValue(ListBox1.SelectedItem.ToString.Remove(0, 8))
MessageBox.Show(”Registry Key Information: ” & vbNewLine & ” ” & “HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run\” & ListBox1.SelectedItem.ToString.Remove(0,
& vbNewLine & ” ” & Reg, “Startup Key”, MessageBoxButtons.OK, MessageBoxIcon.Information)
ElseIf Mid(ListBox1.SelectedItem, 1, 2) = “Us” Then
Dim name As String = ListBox1.SelectedItem.ToString.Remove(0, 4) & “.lnk”
name = My.Computer.FileSystem.SpecialDirectories.Programs & “\Startup” & name
MessageBox.Show(”Startup Link File Information: ” & vbNewLine & ” ” & name, “Startup Link”, MessageBoxButtons.OK, MessageBoxIcon.Information)
ElseIf Mid(ListBox1.SelectedItem, 1, 2) = “Al” Then
Dim name As String = ListBox1.SelectedItem.ToString.Remove(0,
& “.lnk”
name = “C:\Documents and Settings\All Users\Start Menu\Programs\Startup” & name
MessageBox.Show(”Startup Link File Information: ” & vbNewLine & ” ” & name, “Startup Link”, MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
ListBox1.Items.Clear()
For Each file As String In My.Computer.FileSystem.GetFiles(My.Computer.FileSystem.SpecialDirectories.Programs & “\Startup”)
If My.Computer.FileSystem.GetFileInfo(file).Extension = “.lnk” Then
Dim name As String = My.Computer.FileSystem.GetName(file)
name = name.Remove(name.Length - 4, 4)
ListBox1.Items.Add(”User\” & name)
End If
Next
Dim path As String = “C:\Documents and Settings\All Users\Start Menu\Programs\Startup”
For Each file As String In My.Computer.FileSystem.GetFiles(path)
If My.Computer.FileSystem.GetFileInfo(file).Extension = “.lnk” Then
Dim name As String = My.Computer.FileSystem.GetName(file)
name = name.Remove(name.Length - 4, 4)
ListBox1.Items.Add(”All Users\” & name)
End If
Next
Dim Reg1 As Microsoft.Win32.RegistryKey
Reg1 = My.Computer.Registry.CurrentUser.OpenSubKey(”Software\Microsoft\Windows\CurrentVersion\Run”, True)
For Each nod As String In Reg1.GetValueNames
ListBox1.Items.Add(”Current\” & nod)
Next
Dim Reg2 As Microsoft.Win32.RegistryKey
Reg2 = My.Computer.Registry.LocalMachine.OpenSubKey(”Software\Microsoft\Windows\CurrentVersion\Run”, True)
For Each nod As String In Reg2.GetValueNames
ListBox1.Items.Add(”Machine\” & nod)
Next
End Sub
End Class
Comments(0)