mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 19:57:57 +01:00
[runner]Fix non-elevated restart loop (#17853)
This commit is contained in:
@@ -443,10 +443,9 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
|||||||
if (is_restart_scheduled())
|
if (is_restart_scheduled())
|
||||||
{
|
{
|
||||||
if (!restart_if_scheduled())
|
if (!restart_if_scheduled())
|
||||||
|
|
||||||
{
|
{
|
||||||
Logger::warn("Scheduled restart failed. Trying restart as admin as fallback...");
|
// If it's not possible to restart non-elevated due to some condition in the user's configuration, user should start PowerToys manually.
|
||||||
restart_same_elevation();
|
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();
|
stop_tray_icon();
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ bool restart_if_scheduled()
|
|||||||
case RestartAsElevatedOpenSettings:
|
case RestartAsElevatedOpenSettings:
|
||||||
return run_elevated(exe_path.get(), L"--open-settings");
|
return run_elevated(exe_path.get(), L"--open-settings");
|
||||||
case RestartAsNonElevated:
|
case RestartAsNonElevated:
|
||||||
return run_non_elevated(exe_path.get(), L"--dont-elevate", NULL);
|
return run_non_elevated(exe_path.get(), L"", NULL);
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -52,5 +52,5 @@ bool restart_same_elevation()
|
|||||||
constexpr DWORD exe_path_size = 0xFFFF;
|
constexpr DWORD exe_path_size = 0xFFFF;
|
||||||
auto exe_path = std::make_unique<wchar_t[]>(exe_path_size);
|
auto exe_path = std::make_unique<wchar_t[]>(exe_path_size);
|
||||||
GetModuleFileNameW(nullptr, exe_path.get(), 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);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user