-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
62 lines (56 loc) · 2 KB
/
Copy pathProgram.cs
File metadata and controls
62 lines (56 loc) · 2 KB
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
59
60
61
62
using Avalonia;
using System;
namespace AutoLogout;
class Program
{
// Initialization code. Don't use any Avalonia, third-party APIs or any
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
// yet and stuff might break.
[STAThread]
public static void Main(string[] args)
{
OS.Current.Initialize();
// Handle special parameters
if (args.Contains("--register"))
{
// Register AutoLogout to start automatically on login
// This requires an Admin privileges
if (!Environment.IsPrivilegedProcess)
{
Console.WriteLine("--register was called without admin privileges");
return;
}
OS.Current.RegisterStartup(true);
return;
}
if (args.Contains("--unregister"))
{
// Unregister AutoLogout so it no longer starts automatically on login
// This requires an Admin privileges
if (!Environment.IsPrivilegedProcess)
{
Console.WriteLine("--unregister was called without admin privileges");
return;
}
OS.Current.RegisterStartup(false);
return;
}
State.Current.Load();
if (args.Contains("--service"))
{
// The --service tag indicates that AutoLogout launched automatically from any account
// In this state, AutoLogout shouldn't be running if it hasn't already been setup for this account
if(State.Current.Intent == UserIntent.Setup) return;
}
BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);
}
// Avalonia configuration, don't remove; also used by visual designer.
public static AppBuilder BuildAvaloniaApp()
=> AppBuilder.Configure<App>()
.UsePlatformDetect()
#if DEBUG
.WithDeveloperTools()
#endif
.WithInterFont()
.LogToTrace();
}