-
Notifications
You must be signed in to change notification settings - Fork 85
/
Copy pathProgram.cs
45 lines (42 loc) · 1.39 KB
/
Program.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
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
namespace TrustProcessLauncher
{
internal class Program
{
[STAThread]
static void Main(string[] args)
{
string ProcessPath = Path.GetDirectoryName(Path.GetDirectoryName(Environment.ProcessPath));
switch (args.LastOrDefault())
{
case "--MonitorTrustProcess":
{
ProcessPath = Path.Combine(ProcessPath, "MonitorTrustProcess\\MonitorTrustProcess.exe");
break;
}
case "--AuxiliaryTrustProcess":
{
ProcessPath = Path.Combine(ProcessPath, "AuxiliaryTrustProcess\\AuxiliaryTrustProcess.exe");
break;
}
default:
{
throw new NotSupportedException();
}
}
if (File.Exists(ProcessPath))
{
using (Process FullTrustProcess = Process.Start(ProcessPath))
{
if ((FullTrustProcess?.HasExited).GetValueOrDefault(true))
{
throw new Exception($"Unable to launch the full trust process, path: {ProcessPath}");
}
}
}
}
}
}