Auto escalate privileges

This commit is contained in:
zone117x
2015-04-19 01:15:02 -06:00
parent 58ea700d37
commit b353022945
5 changed files with 28 additions and 3 deletions

View File

@@ -149,6 +149,9 @@
<Content Include="WebContent\crissXcross.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="WebContent\favicon.ico">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="WebContent\handlebars-v3.0.1.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>

View File

@@ -3,6 +3,7 @@ using NLog.Config;
using NLog.Targets;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
@@ -71,5 +72,12 @@ namespace Jackett
Application.Run(new Main());
}
static public void RestartAsAdmin()
{
var startInfo = new ProcessStartInfo(Application.ExecutablePath.ToString()) { Verb = "runas" };
Process.Start(startInfo);
Environment.Exit(0);
}
}
}

View File

@@ -56,11 +56,23 @@ namespace Jackett
Process.Start("http://127.0.0.1:" + Port);
}
catch (HttpListenerException ex)
{
var dialogResult = MessageBox.Show(
"App must be ran as Admin for permission to use port " + Port + Environment.NewLine + "Restart app with admin privileges?",
"Failed to open port",
MessageBoxButtons.YesNo
);
if (dialogResult == DialogResult.No)
{
Program.LoggerInstance.FatalException("App must be ran as Admin for permission to use port " + Port, ex);
Application.Exit();
return;
}
else
{
Program.RestartAsAdmin();
}
}
catch (Exception ex)
{
Program.LoggerInstance.ErrorException("Error: " + ex.Message, ex);

Binary file not shown.

After

Width:  |  Height:  |  Size: 361 KiB

View File

@@ -4,6 +4,8 @@
<head>
<meta charset="utf-8" />
<link rel='shortcut icon' type='image/x-icon' href='/favicon.ico' />
<script src="jquery-2.1.3.min.js"></script>
<script src="handlebars-v3.0.1.js"></script>
<script src="bootstrap/bootstrap.min.js"></script>