Multipurpose utility for managing Games for Windows - LIVE installs and content. (Mirrored from https://github.com/InvoxiPlayGames/GfWLUtility)
at master 1.4 kB view raw
1using System; 2using System.Collections.Generic; 3using System.Diagnostics; 4using System.Linq; 5using System.Reflection; 6using System.Security.Principal; 7using System.Windows.Forms; 8 9namespace GfWLUtility 10{ 11 internal static class Program 12 { 13 public static bool Elevated = false; 14 15 public static string[] Arguments = null; 16 17 /// <summary> 18 /// The main entry point for the application. 19 /// </summary> 20 [STAThread] 21 static void Main(string[] args) 22 { 23 // store arguments 24 Arguments = args; 25 26 // store elevation status 27 WindowsIdentity identity = WindowsIdentity.GetCurrent(); 28 WindowsPrincipal principal = new WindowsPrincipal(identity); 29 Elevated = principal.IsInRole(WindowsBuiltInRole.Administrator); 30 31 // start the application 32 Application.EnableVisualStyles(); 33 Application.SetCompatibleTextRenderingDefault(false); 34 Application.Run(new MainWindow()); 35 } 36 37 public static void RelaunchAsAdmin(string arguments = null) 38 { 39 Process p = new Process(); 40 p.StartInfo.FileName = Assembly.GetExecutingAssembly().Location; 41 p.StartInfo.Arguments = arguments; 42 p.StartInfo.UseShellExecute = true; 43 p.StartInfo.Verb = "runas"; 44 p.Start(); 45 Application.Exit(); 46 } 47 } 48}