Run application in as administrator in c sharp
start your application in administrator permissions using c sharp
using System.Diagnostics;using System.Security.Permissions;
using System.Threading;
using System.Security.Principal;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
button1.Text = "Run Firefox with administrator permission";
}
private void button1_Click(object sender, EventArgs e)
{
MyMethod();
}
public void MyMethod()
{
ProcessStartInfo info = new ProcessStartInfo(@"C:\Program Files\Mozilla Firefox 13\firefox.exe");
if (System.Environment.OSVersion.Version.Major >= 6)
{
info.Verb = "runas";
}
Process p = Process.Start(info);
}
}
}
Output Image
By:VidyaGyan