Code:
Create registry:
RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true); key.SetValue("Tutorial", Application.ExecutablePath); key.Close(); MessageBox.Show("Success");
Remove registry:
RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true); key.DeleteValue("Tutorial"); key.Close(); MessageBox.Show("Success");
Create file:
File.Copy(Application.ExecutablePath, @"C:\Users\VB\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\tutorial.exe");
Delete file:
File.Delete(@"C:\Users\VB\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\tutorial.exe");