Skip to content

Commit

Permalink
[runner]Fix non-elevated restart loop (#17853)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaimecbernardo committed Apr 21, 2022
1 parent b463cb1 commit d683ab0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions src/runner/main.cpp
Expand Up @@ -443,10 +443,9 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
if (is_restart_scheduled())
{
if (!restart_if_scheduled())

{
Logger::warn("Scheduled restart failed. Trying restart as admin as fallback...");
restart_same_elevation();
// If it's not possible to restart non-elevated due to some condition in the user's configuration, user should start PowerToys manually.
Logger::warn("Scheduled restart failed. Couldn't restart non-elevated. PowerToys exits here because retrying it would just mean failing in a loop.");
}
}
stop_tray_icon();
Expand Down
4 changes: 2 additions & 2 deletions src/runner/restart_elevated.cpp
Expand Up @@ -41,7 +41,7 @@ bool restart_if_scheduled()
case RestartAsElevatedOpenSettings:
return run_elevated(exe_path.get(), L"--open-settings");
case RestartAsNonElevated:
return run_non_elevated(exe_path.get(), L"--dont-elevate", NULL);
return run_non_elevated(exe_path.get(), L"", NULL);
default:
return false;
}
Expand All @@ -52,5 +52,5 @@ bool restart_same_elevation()
constexpr DWORD exe_path_size = 0xFFFF;
auto exe_path = std::make_unique<wchar_t[]>(exe_path_size);
GetModuleFileNameW(nullptr, exe_path.get(), exe_path_size);
return run_same_elevation(exe_path.get(), L"--dont-elevate", nullptr);
return run_same_elevation(exe_path.get(), L"", nullptr);
}

0 comments on commit d683ab0

Please sign in to comment.