using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Security.Principal; using System.Threading.Tasks; using System.Windows.Forms; namespace updateServer { static class Program { /// /// 해당 응용 프로그램의 주 진입점입니다. /// [STAThread] static void Main() { /* Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); mMainForm = new Form1(); Application.Run(mMainForm); */ if (IsAdministrator() == false) { ProcessStartInfo processStartInfo = new ProcessStartInfo(); processStartInfo.UseShellExecute = true; processStartInfo.FileName = Application.ExecutablePath; processStartInfo.WorkingDirectory = Environment.CurrentDirectory; processStartInfo.Verb = "runas"; Process.Start(processStartInfo); } else { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); mMainForm = new Form1(); Application.Run(mMainForm); } } public static bool IsAdministrator() { WindowsIdentity identity = WindowsIdentity.GetCurrent(); if (identity != null) { WindowsPrincipal principal = new WindowsPrincipal(identity); return principal.IsInRole(WindowsBuiltInRole.Administrator); } return false; } public static Form1 mMainForm = null; } }