From 13c2ce3f31e10ced27f2fe3dfae86be0c37f6d33 Mon Sep 17 00:00:00 2001 From: Andrey Nekrasov Date: Fri, 17 Jul 2020 11:51:20 +0300 Subject: [PATCH] autoupdate: wait for the .exe updater to exit before restarting PowerToys (#5004) --- src/action_runner/action_runner.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/action_runner/action_runner.cpp b/src/action_runner/action_runner.cpp index fe1ea4ac73..07a9a1365f 100644 --- a/src/action_runner/action_runner.cpp +++ b/src/action_runner/action_runner.cpp @@ -111,11 +111,17 @@ bool install_new_version_stage_2(std::wstring installer_path, std::wstring_view { // If it's not .msi, then it's our .exe installer SHELLEXECUTEINFOW sei{ sizeof(sei) }; - sei.fMask = { SEE_MASK_FLAG_NO_UI | SEE_MASK_NOASYNC }; + sei.fMask = { SEE_MASK_FLAG_NO_UI | SEE_MASK_NOASYNC | SEE_MASK_NOCLOSEPROCESS | SEE_MASK_NO_CONSOLE}; sei.lpFile = installer_path.c_str(); sei.nShow = SW_SHOWNORMAL; success = ShellExecuteExW(&sei) == TRUE; + // Wait for the install completion + if (success) + { + WaitForSingleObject(sei.hProcess, INFINITE); + CloseHandle(sei.hProcess); + } } std::error_code _;