-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAutorun.cs
More file actions
20 lines (17 loc) · 856 Bytes
/
Copy pathAutorun.cs
File metadata and controls
20 lines (17 loc) · 856 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
using Microsoft.Win32;
namespace AutoTotal {
internal static class Autorun {
public static void Add() {
using RegistryKey run = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true)!;
run.SetValue("AutoTotal", AppDomain.CurrentDomain.BaseDirectory + "AutoTotal.exe /autorun");
}
public static void Remove() {
using RegistryKey run = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true)!;
run.DeleteValue("AutoTotal", false);
}
public static bool Exists() {
using RegistryKey run = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", false)!;
return !string.IsNullOrEmpty(run.GetValue("AutoTotal") as string);
}
}
}