title: A program added to autoload does not start C #
body: <p>Who can help? I need the program to throw itself into startup. I tried a lot that did not help for example:</p>
  
  <p>There is one more news that my exe file does not start via cmd (command line); any other application launches mine no
  I write so start the path to the program I tried on d and c \ .exe</p>
  
  <p>Through the code</p>
  
  <pre><code>Registry.CurrentUser.CreateSubKey (@ "Software \ Microsoft \ Windows \ CurrentVersion \ Run;
  </code></pre>
  
  <p>(does not work) it just doesn't start, it's as if it is there and it is on it doesn't start it I tried it through the other folder and through the USB flash drive evenly!</p>
  
  <p>I tried to copy it to the startup folder manually, it launches fine, it starts up and everything works, but it can't throw its own shortcut saying that there are no admin rights, in the manifest it changed the launch line from the admin to the normal one and back when it is from the admin even when I manually threw it. I tried to move files through bad</p>
  
  <p>The examples below do not work either. </p>
  
  <pre><code>RegistryKey rk = Registry.CurrentUser.OpenSubKey ("SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Run", true); rk.SetValue ("FileName", "FileName.exe");
  </code></pre>
  
  <p>If you manually place the full path to the program in <code>HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Run</code> - does it work?</p>
  
  <p>My code is:</p>
  
  <pre><code>public bool SetAutorunValue(bool autorun)
  {
      string ExePath = Application.ExecutablePath;
      RegistryKey reg;
      reg = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
      if (autorun)
      {
          if (reg.GetValue(NameApp) == null)
          {
              reg.SetValue(NameApp, ExePath);
              reg.Close();
              return true;
          }
          else
              return false;
      }
      else
      {
          if (reg.GetValue(NameApp) != null)
          {
              reg.DeleteValue(NameApp);
              reg.Close();
              return true;
          }
          else
              return false;
      }
  }
  </code></pre>