-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAutorun+Blocker.cs
32 lines (26 loc) · 1.16 KB
/
Autorun+Blocker.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using Microsoft.Win32;
using System.IO;
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);
}
}
internal static class Blocker {
public static void Block(string path) {
File.WriteAllText(path + ":Zone.Identifier:$DATA", "[ZoneTransfer]\nZoneId=4");
}
public static void Unblock(string path) {
File.Delete(path + ":Zone.Identifier:$DATA");
}
}
}