This repository was archived by the owner on Jun 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
51 lines (49 loc) · 1.31 KB
/
Program.cs
File metadata and controls
51 lines (49 loc) · 1.31 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using SPMinstaller;
using System.Security.Principal;
namespace SPMinstaller
{
internal static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
public static void Main(string[] args)
{
if (args.Length == 0)
{
if (!IsAdministrator())
{
MessageBox.Show("You must run this program as administrator.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
System.Environment.Exit(1);
}
else
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new SPMinstaller());
}
}
else if (args.Length == 1 && args[0]=="-q")
{
if (IsAdministrator())
{
SPMinstaller.desktopshortcut = true;
SPMinstaller.startmenushorcut = true;
SPMinstaller.Install();
}
else MessageBox.Show("You need to run this program as administrator", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
public static bool IsAdministrator()
{
return (new WindowsPrincipal(WindowsIdentity.GetCurrent()))
.IsInRole(WindowsBuiltInRole.Administrator);
}
}
}