Skip to content

Commit

Permalink
.fix:bug change start permission
Browse files Browse the repository at this point in the history
  • Loading branch information
Fhwang0926 committed May 31, 2020
1 parent 8e9cf3e commit b638e69
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public partial class Form1 : Form
private Int16 ModeSlow = 5000;
private Int16 ModeNormarl = 3000;
private Int16 ModeFast = 1000;
private string VERSION = "v0.8.26";
private string VERSION = "v0.8.27";
private string GITHUB = "https://github.com/Fhwang0926/CoreTracker";

private bool mouseDown;
Expand Down Expand Up @@ -549,5 +549,6 @@ private bool toggleTraySetting()






20 changes: 20 additions & 0 deletions Lib/Program.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Security.Principal;
using System.Windows.Forms;

namespace CoreTracker
{
static class Program
{
public static bool IsAdministrator()
{
WindowsIdentity identity = WindowsIdentity.GetCurrent();
WindowsPrincipal principal = new WindowsPrincipal(identity);
return principal.IsInRole(WindowsBuiltInRole.Administrator);
}
/// <summary>
/// 해당 애플리케이션의 주 진입점입니다.
/// </summary>
Expand All @@ -15,6 +23,18 @@ static void Main(string[] args)
{
try
{
if (!Program.IsAdministrator())
{
// Restart and run as admin
var exeName = Process.GetCurrentProcess().MainModule.FileName;
ProcessStartInfo startInfo = new ProcessStartInfo(exeName);
startInfo.Verb = "runas";
startInfo.Arguments = "restart";
Process.Start(startInfo);
Application.Exit();
return;
}
// real start
System.Threading.Mutex mutex = new System.Threading.Mutex(false, System.Diagnostics.Process.GetCurrentProcess().ProcessName);
try
{
Expand Down

0 comments on commit b638e69

Please sign in to comment.