SoFunction
Updated on 2025-04-06

C# Set the startup item and cancel the startup item

If you want the program you write to start with the system booting, then you can do it according to the following method.

RunWhenStart(false, ,  + @\"\\\"); 



    /// <summary> 
    /// Startup item    /// </summary> 
    /// <param name=\"Started\">Whether to start</param>    /// <param name=\"name\">Name of the startup value</param>    /// <param name=\"path\">Path to start the program</param>    public static void RunWhenStart(bool Started, string name, string path) 
    { 
      RegistryKey HKLM = ; 
      RegistryKey Run = (@\"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run\"); 
      if (Started == true) 
      { 
        try 
        { 
          (name, path); 
          (); 
        } 
        catch (Exception Err) 
        { 
          ((), \"MUS\", , ); 
        } 
      } [Page]
      else 
      { 
        try 
        { 
          (name); 
          (); 
        } 
        catch (Exception) 
        { 
          // 
        } 
      } 
    }