[Runner] Open settings when restarted as admin (#9463)

* open settings from runner

* Update src/runner/main.cpp

* Update src/runner/main.cpp

Co-authored-by: Enrico Giordani <enricogior@users.noreply.github.com>
This commit is contained in:
Davide Giacometti
2021-02-10 14:48:43 +01:00
committed by GitHub
parent d92ff6d45d
commit 3715b8c5f2
4 changed files with 19 additions and 8 deletions

View File

@@ -77,7 +77,7 @@ void open_menu_from_another_instance()
PostMessageW(hwnd_main, WM_COMMAND, ID_SETTINGS_MENU_COMMAND, 0);
}
int runner(bool isProcessElevated)
int runner(bool isProcessElevated, bool openSettings)
{
std::filesystem::path logFilePath(PTSettingsHelper::get_root_save_folder_location());
logFilePath.append(LogSettings::runnerLogPath);
@@ -156,6 +156,11 @@ int runner(bool isProcessElevated)
Trace::EventLaunch(get_product_version(), isProcessElevated);
if (openSettings)
{
open_settings_window();
}
result = run_message_loop();
}
catch (std::runtime_error& err)
@@ -404,6 +409,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
modules();
auto general_settings = load_general_settings();
const bool openSettings = std::string(lpCmdLine).find("--open-settings") != std::string::npos;
// Apply the general settings but don't save it as the modules() variable has not been loaded yet
apply_general_settings(general_settings, false);
@@ -411,13 +417,14 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
const bool elevated = is_process_elevated();
if ((elevated ||
general_settings.GetNamedBoolean(L"run_elevated", false) == false ||
strcmp(lpCmdLine, "--dont-elevate") == 0))
std::string(lpCmdLine).find("--dont-elevate") != std::string::npos))
{
result = runner(elevated);
result = runner(elevated, openSettings);
}
else
{
schedule_restart_as_elevated();
schedule_restart_as_elevated(openSettings);
result = 0;
}
}