导航

 public static bool SetAutoRun(string keyName,string filePath)
        {
           
try
            {
                RegistryKey runKey
=Registry.LocalMachine.OpenSubKey(@"\SOFTWARE\Microsoft\Windows\CurrentVersion\Run",true);
                runKey.SetValue(keyName,filePath);
                runKey.Close();
            }
           
catch
            {
               
return false;
            }
           
return true;
        }

test: SetAutoRun(
"myexe","c:\\text.exe");