# HG changeset patch # User Steve Dower # Date 1441994050 25200 # Fri Sep 11 10:54:10 2015 -0700 # Branch 3.5 # Node ID d453ea7cd3ff3038a4d176bea910b52f94be8124 # Parent 6063fba0e28a37c8fd1d95e30e1949c517f5e93a Issue #25071: Windows installer requires TargetDir parameter when installing quietly diff --git a/Tools/msi/bundle/bootstrap/PythonBootstrapperApplication.cpp b/Tools/msi/bundle/bootstrap/PythonBootstrapperApplication.cpp --- a/Tools/msi/bundle/bootstrap/PythonBootstrapperApplication.cpp +++ b/Tools/msi/bundle/bootstrap/PythonBootstrapperApplication.cpp @@ -723,6 +723,36 @@ hrStatus = EvaluateConditions(); } + if (SUCCEEDED(hrStatus)) { + // Ensure the default path has been set + LONGLONG installAll; + LPWSTR targetDir = nullptr; + LPWSTR defaultTargetDir = nullptr; + + hrStatus = BalGetStringVariable(L"TargetDir", &targetDir); + if (FAILED(hrStatus) || !targetDir || !targetDir[0]) { + ReleaseStr(targetDir); + targetDir = nullptr; + + if (FAILED(BalGetNumericVariable(L"InstallAllUsers", &installAll))) { + installAll = 0; + } + + hrStatus = BalGetStringVariable( + installAll ? L"DefaultAllUsersTargetDir" : L"DefaultJustForMeTargetDir", + &defaultTargetDir + ); + + if (SUCCEEDED(hrStatus) && defaultTargetDir) { + if (defaultTargetDir[0] && SUCCEEDED(BalFormatString(defaultTargetDir, &targetDir))) { + hrStatus = _engine->SetVariableString(L"TargetDir", targetDir); + ReleaseStr(targetDir); + } + ReleaseStr(defaultTargetDir); + } + } + } + SetState(PYBA_STATE_DETECTED, hrStatus); // If we're not interacting with the user or we're doing a layout or we're just after a force restart