static bool EnsureRunningAsAdministrator(string[] arguments)
{
try
{
if(!IsElevated())
{
ProcessStartInfo startInfo = new ProcessStartInfo(Assembly.GetExecutingAssembly().Location) { Verb = "runas", Arguments = string.Join(" ", arguments) };
Process process = new Process { StartInfo = startInfo };
try
{
process.Start();
}
catch(Exception e)
{
LogException(e);
}
return false;
}
}
catch(Exception e)
{
LogException(e);
}
return true;
}