If process elevated and --dont-elevate arg - run non elevated (#15920)

This commit is contained in:
Stefan Markovic
2022-02-02 11:23:40 +01:00
committed by GitHub
parent 51a43d58de
commit 0fc69ca222
2 changed files with 8 additions and 2 deletions

View File

@@ -148,7 +148,7 @@
Impersonate="yes"
Return="asyncNoWait"
FileKey="PowerToys.exe"
ExeCommand="" />
ExeCommand="--dont-elevate" />
<CustomAction
Id="TerminateProcesses"

View File

@@ -386,7 +386,13 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
apply_general_settings(general_settings, false);
int rvalue = 0;
const bool elevated = is_process_elevated();
if ((elevated ||
if (elevated && cmdLine.find("--dont-elevate") != std::string::npos &&
general_settings.GetNamedBoolean(L"run_elevated", false) == false) {
schedule_restart_as_non_elevated();
result = 0;
}
else if ((elevated ||
general_settings.GetNamedBoolean(L"run_elevated", false) == false ||
cmdLine.find("--dont-elevate") != std::string::npos))
{