none
how to remove my app from startup ?

    Question

  • Hi friends Im using vb2005 an am BEGINNER in programming and I need to no how to remove my app from startup programs I use this code to add my app to startup programs so how to remove it?
    Tuesday, June 07, 2011 10:10 AM

Answers

  • Hi Oman,

     

    Providing you code for you.

     

    Private Sub AddCurrentKey(ByVal name As String, ByVal path As String) ' Adds to startup
            Dim key As RegistryKey = Registry.CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Run", True)
            key.SetValue(name, path)
    End Sub
     
    Private Sub RemoveCurrentKey(ByVal name As String) ' Removes from startup
            Dim key As RegistryKey = Registry.CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Run", True)
            key.DeleteValue(name, False)
    End Sub
     
    To add the key:
    AddCurrentKey("StartupExample", System.Reflection.Assembly.GetEntryAssembly.Location)
     
    To remove the key:
    RemoveCurrentKey("StartupExample")

     

    Hope you will find this information helpful

    Regards,

    Umisha

    Source Code-World

     

    • Marked as answer by config2002 Wednesday, June 08, 2011 9:40 PM
    Tuesday, June 07, 2011 10:18 AM

All replies

  • Hi Oman,

     

    Providing you code for you.

     

    Private Sub AddCurrentKey(ByVal name As String, ByVal path As String) ' Adds to startup
            Dim key As RegistryKey = Registry.CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Run", True)
            key.SetValue(name, path)
    End Sub
     
    Private Sub RemoveCurrentKey(ByVal name As String) ' Removes from startup
            Dim key As RegistryKey = Registry.CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Run", True)
            key.DeleteValue(name, False)
    End Sub
     
    To add the key:
    AddCurrentKey("StartupExample", System.Reflection.Assembly.GetEntryAssembly.Location)
     
    To remove the key:
    RemoveCurrentKey("StartupExample")

     

    Hope you will find this information helpful

    Regards,

    Umisha

    Source Code-World

     

    • Marked as answer by config2002 Wednesday, June 08, 2011 9:40 PM
    Tuesday, June 07, 2011 10:18 AM
  • thanks Umisha

     

     Dim key As RegistryKey = Registry.CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Run", True) 
    
    
     key.DeleteValue(<strong><span style="text-decoration:underline">name</span></strong>, False)
    
    

     name  in this code shall I leave it as it or replace it with my app's name?

     


    Tuesday, June 07, 2011 11:07 PM
  • Did you put anything in the registry to start with? If you just put it in the startup folder, just delete it.

    Sorry if my English is poor, it's not my first language. :) Programming FTW! Samuel
    Useful links:
    Wednesday, June 08, 2011 12:07 AM
  • thanks Umisha

    the whole code

    General
    
    Imports Microsoft.Win32 
    
    Code:- To Add Key
    
     Dim Path As String = Application.StartupPath & "\Application's name.exe"
    
      Dim key As RegistryKey
    
      key = Registry.CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Run", True)
    
      key.SetValue(Name,Path)
    
    Code:- To Remove Key
    
     Dim key As RegistryKey
    
      key = Registry.CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Run", True)
    
      key.DeleteValue(Name, False)
    
    =================================================================================================
    
    Ex:
    
     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 
    
    
    
    Button1.Click
    
      Dim s As String = Application.StartupPath & "\Aiv.exe"
    
      Dim key As RegistryKey
    
      key = Registry.CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Run", True)
    
      key.SetValue(Name, s)
    
     End Sub
    
    
    
     
    
     
    
     
    
     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 
    
    
    
    Button2.Click
    
      Dim key As RegistryKey
    
      key = Registry.CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Run", True)
    
      key.DeleteValue(Name, False)
    
     End Sub
    
    

     


    Wednesday, June 08, 2011 9:39 PM