@joebigelow / wix / commits / b20a7791

WIXFEAT:6195 - Don't change current directory for ExePackage.

Sean Hall committed Dec 15, 2020 at 20:03 UTC b20a77911c6a2b096f021639e0daadae7430091c
1 file changed +2 -14
src/engine/exeengine.cpp
+2 -14
@@ -377,8 +377,6 @@ extern "C" HRESULT ExeEngineExecutePackage(
377 )
378 {
379 HRESULT hr = S_OK;
380 - WCHAR wzCurrentDirectory[MAX_PATH] = { };
381 - BOOL fChangedCurrentDirectory = FALSE;
380 int nResult = IDNOACTION;
381 LPCWSTR wzArguments = NULL;
382 LPWSTR sczArguments = NULL;
@@ -535,13 +533,8 @@ extern "C" HRESULT ExeEngineExecutePackage(
533 {
534 // Make the cache location of the executable the current directory to help those executables
535 // that expect stuff to be relative to them.
538 - if (::GetCurrentDirectoryW(countof(wzCurrentDirectory), wzCurrentDirectory))
539 - {
540 - fChangedCurrentDirectory = ::SetCurrentDirectoryW(sczCachedDirectory);
541 - }
542 -
543 - si.cb = sizeof(si); // TODO: hookup the stdin/stdout/stderr pipes for logging purposes?
544 - if (!::CreateProcessW(sczExecutablePath, sczCommand, NULL, NULL, TRUE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi))
536 + si.cb = sizeof(si);
537 + if (!::CreateProcessW(sczExecutablePath, sczCommand, NULL, NULL, TRUE, CREATE_NO_WINDOW, NULL, sczCachedDirectory, &si, &pi))
538 {
539 ExitWithLastError(hr, "Failed to CreateProcess on path: %ls", sczExecutablePath);
540 }
@@ -573,11 +566,6 @@ extern "C" HRESULT ExeEngineExecutePackage(
566 ExitOnRootFailure(hr, "Process returned error: 0x%x", dwExitCode);
567
568 LExit:
576 - if (fChangedCurrentDirectory)
577 - {
578 - ::SetCurrentDirectoryW(wzCurrentDirectory);
579 - }
580 -
569 StrSecureZeroFreeString(sczArguments);
570 StrSecureZeroFreeString(sczArgumentsFormatted);
571 ReleaseStr(sczArgumentsObfuscated);