| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 | 
							- using InABox.Configuration;
 
- using InABox.Core;
 
- using InABox.Wpf;
 
- using PRSServices;
 
- using Syncfusion.Licensing;
 
- using System;
 
- using System.Collections.Generic;
 
- using System.Configuration;
 
- using System.Data;
 
- using System.Diagnostics;
 
- using System.IO;
 
- using System.Linq;
 
- using System.Reflection;
 
- using System.Security.Principal;
 
- using System.ServiceProcess;
 
- using System.Threading.Tasks;
 
- using System.Windows;
 
- namespace PRSLicensing;
 
- /// <summary>
 
- /// Interaction logic for App.xaml
 
- /// </summary>
 
- public partial class App : Application
 
- {
 
-     static App()
 
-     {
 
-         PRSServiceInstaller.Assembly = typeof(App).Assembly;
 
-     }
 
-     private AdminStartup CheckAdmin()
 
-     {
 
-         if (!IsRunAsAdmin())
 
-         {
 
-             var proc = new ProcessStartInfo();
 
-             proc.UseShellExecute = true;
 
-             proc.WorkingDirectory = Environment.CurrentDirectory;
 
-             proc.FileName =
 
-                 Path.ChangeExtension(Assembly.GetEntryAssembly().Location, "exe"); // Required to change to exe because .NET produces a .dll
 
-             proc.Verb = "runas";
 
-             try
 
-             {
 
-                 Process.Start(proc);
 
-                 Shutdown(0);
 
-                 return AdminStartup.Done;
 
-             }
 
-             catch (Exception ex)
 
-             {
 
-                 MessageWindow.ShowMessage("This program must be run as an administrator! \n\n" + ex, "Administrator required");
 
-             }
 
-             return AdminStartup.Cannot;
 
-         }
 
-         return AdminStartup.Already;
 
-     }
 
-     private static bool IsRunAsAdmin()
 
-     {
 
-         try
 
-         {
 
-             var id = WindowsIdentity.GetCurrent();
 
-             var principal = new WindowsPrincipal(id);
 
-             return principal.IsInRole(WindowsBuiltInRole.Administrator);
 
-         }
 
-         catch (Exception)
 
-         {
 
-             return false;
 
-         }
 
-     }
 
-     protected override void OnStartup(StartupEventArgs e)
 
-     {
 
-         SyncfusionLicenseProvider.RegisterLicense(CoreUtils.SyncfusionLicense(SyncfusionVersion.v25_2));
 
-         if (Environment.UserInteractive)
 
-         {
 
-             var args = Environment.GetCommandLineArgs();
 
-             if (args.Length <= 1)
 
-             {
 
-                 if (CheckAdmin() != AdminStartup.Cannot)
 
-                 {
 
-                     var f = new Console();
 
-                     f.ShowDialog();
 
-                     Shutdown(0);
 
-                 }
 
-                 else
 
-                 {
 
-                     MessageWindow.ShowMessage("This program must be run as Admin!", "Administrator required");
 
-                     Shutdown(0);
 
-                 }
 
-             }
 
-             else if (args[1].StartsWith("/service="))
 
-             {
 
-                 var c = new LicensingConsole(args[1].Split('=').Last(), args[1].Split('=').Last(), false);
 
-                 c.ShowDialog();
 
-                 Shutdown(0);
 
-             }
 
-             else
 
-             {
 
-                 Shutdown(0);
 
-             }
 
-         }
 
-         else
 
-         {
 
-             var args = Environment.GetCommandLineArgs();
 
-             var serviceName = "";
 
-             if (args.Length > 1 && args[1].StartsWith("/service=")) serviceName = args[1].Split('=').Last();
 
-             ServiceBase.Run(new PRSLicensingService(serviceName));
 
-             Shutdown(0);
 
-         }
 
-     }
 
-     private enum AdminStartup
 
-     {
 
-         Already,
 
-         Done,
 
-         Cannot
 
-     }
 
- }
 
 
  |