I'm currently using this code to restart app with admin rights.
// If application can not write to path, alert user.
if (!pathiswritable)
{
if (MessageBox.Show("The application cannot use the current location\nRestart as administrator?",
"Need elevation",
MessageBoxButtons.YesNo) != DialogResult.Yes)
{
Exit(ExitError.NOT_WRITABLE_USER);
}
ProcessStartInfo SelfProc = new ProcessStartInfo
{
UseShellExecute = true,
WorkingDirectory = Environment.CurrentDirectory,
FileName = Application.ExecutablePath,
Verb = "runas"
};
try
{
Process.Start(SelfProc);
Environment.Exit(0);
}
catch(Exception)
{
Exit(ExitError.NO_ELEVATE);
}
}
But I'd like to make it clear with that admin shield icon on the yes button, that will restart as admin.
Wondering if there is a .net solution for this, or do I need to use unmanaged code?