Posts Tagged ‘Autostart’

C# Autostart

Montag, August 30th, 2010

 
 

  1. Prüfen ob eine Anwendung im Autostart eingetragen ist

    public static bool RunOnStartupCurrentUser( string applicationName )
         {
             RegistryKey regkey = Registry.CurrentUser.OpenSubKey
                 ( “SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run”true );
             if ( regkey.GetValue(applicationName) == null )
                 {
                 return false;
                 }
             else
                 {
                 return true;
                 }
         }

 
 

  1. Anwendung in der registry eintragen

    public static void AddCurrentUser(string executablePath, string applicationName)
        {
           RegistryKey regkey = Registry.CurrentUser.OpenSubKey
                ( “SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run”true );
            regkey.SetValue( applicationName, executablePath );
        }

     
     

  2. Anwendung aus der Registry löschen

    public static void RemoveCurrentUser(string applicationName)
        {
        RegistryKey regkey = Registry.CurrentUser.OpenSubKey
            ( “SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run”true );
        regkey.DeleteValue(applicationName,true);
        }

 
 

Mit msconfig.exe last sich dann auch noch recht einfach prüfen ob

die Werte wirklich eingetragen wurden.

Mehr gibt es nicht zu tun.

Share and Enjoy:
  • Print
  • Facebook
  • Twitter
  • Google Bookmarks
  • Live
  • PDF