summaryrefslogtreecommitdiff
path: root/src/burn/engine/msuengine.cpp
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2022-03-18 20:15:33 -0500
committerSean Hall <r.sean.hall@gmail.com>2022-03-19 12:07:32 -0500
commitfb54576f1d05e82ba47cd718c4c4f8b3bad624c9 (patch)
treeb7d6b30bd3c9294b74874c1a48b20a8da8869a69 /src/burn/engine/msuengine.cpp
parent581c320e04949300d6c3bee71fb5fc1a557f9263 (diff)
downloadwix-fb54576f1d05e82ba47cd718c4c4f8b3bad624c9.tar.gz
wix-fb54576f1d05e82ba47cd718c4c4f8b3bad624c9.tar.bz2
wix-fb54576f1d05e82ba47cd718c4c4f8b3bad624c9.zip
Give BA process id and option to wait for cancelled process to exit.
Diffstat (limited to 'src/burn/engine/msuengine.cpp')
-rw-r--r--src/burn/engine/msuengine.cpp32
1 files changed, 2 insertions, 30 deletions
diff --git a/src/burn/engine/msuengine.cpp b/src/burn/engine/msuengine.cpp
index 091bbe62..2f1fb61c 100644
--- a/src/burn/engine/msuengine.cpp
+++ b/src/burn/engine/msuengine.cpp
@@ -264,7 +264,6 @@ extern "C" HRESULT MsuEngineExecutePackage(
264 ) 264 )
265{ 265{
266 HRESULT hr = S_OK; 266 HRESULT hr = S_OK;
267 int nResult = IDNOACTION;
268 LPWSTR sczCachedDirectory = NULL; 267 LPWSTR sczCachedDirectory = NULL;
269 LPWSTR sczMsuPath = NULL; 268 LPWSTR sczMsuPath = NULL;
270 LPWSTR sczWindowsPath = NULL; 269 LPWSTR sczWindowsPath = NULL;
@@ -350,35 +349,8 @@ extern "C" HRESULT MsuEngineExecutePackage(
350 hr = EnsureWUServiceEnabled(fStopWusaService, &schWu, &fWuWasDisabled); 349 hr = EnsureWUServiceEnabled(fStopWusaService, &schWu, &fWuWasDisabled);
351 ExitOnFailure(hr, "Failed to ensure WU service was enabled to install MSU package."); 350 ExitOnFailure(hr, "Failed to ensure WU service was enabled to install MSU package.");
352 351
353 // create process 352 hr = ExeEngineRunProcess(pfnGenericMessageHandler, pvContext, pPackage, sczWusaPath, sczCommand, NULL, &dwExitCode);
354 si.cb = sizeof(si); 353 ExitOnFailure(hr, "Failed to run MSU process");
355 if (!::CreateProcessW(sczWusaPath, sczCommand, NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi))
356 {
357 ExitWithLastError(hr, "Failed to CreateProcess on path: %ls", sczWusaPath);
358 }
359
360 do
361 {
362 message.type = GENERIC_EXECUTE_MESSAGE_PROGRESS;
363 message.dwUIHint = MB_OKCANCEL;
364 message.progress.dwPercentage = 50;
365 nResult = pfnGenericMessageHandler(&message, pvContext);
366 hr = (IDOK == nResult || IDNOACTION == nResult) ? S_OK : IDCANCEL == nResult ? HRESULT_FROM_WIN32(ERROR_INSTALL_USEREXIT) : HRESULT_FROM_WIN32(ERROR_INSTALL_FAILURE);
367 ExitOnRootFailure(hr, "Bootstrapper application aborted during MSU progress.");
368
369 // wait for process to terminate
370 hr = ProcWaitForCompletion(pi.hProcess, 500, &dwExitCode);
371 if (HRESULT_FROM_WIN32(WAIT_TIMEOUT) != hr)
372 {
373 ExitOnFailure(hr, "Failed to wait for executable to complete: %ls", sczWusaPath);
374 }
375 } while (HRESULT_FROM_WIN32(WAIT_TIMEOUT) == hr);
376
377 // get process exit code
378 if (!::GetExitCodeProcess(pi.hProcess, &dwExitCode))
379 {
380 ExitWithLastError(hr, "Failed to get process exit code.");
381 }
382 354
383 // We'll normalize the restart required error code from wusa.exe just in case. Most likely 355 // We'll normalize the restart required error code from wusa.exe just in case. Most likely
384 // that on reboot we'll actually get WU_S_REBOOT_REQUIRED. 356 // that on reboot we'll actually get WU_S_REBOOT_REQUIRED.