summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>2022-05-11 11:20:30 +0200
committerSamuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>2022-05-11 11:20:30 +0200
commit1dcdd2543d70348d93d7f8d8d2b95e3bd6515e2c (patch)
tree305616589607c16c29247684cbf61742a1941093
parentRelease 6.3.6.16 (diff)
downloadcore-1dcdd2543d70348d93d7f8d8d2b95e3bd6515e2c.tar.gz
core-1dcdd2543d70348d93d7f8d8d2b95e3bd6515e2c.zip
Add error handling to RenamePrgFolder and RemovePrgFolder
These routines can fail during MSI installation (seen leftover program_old folders, with program folder missing). We at least want to see the error in the MSI log file when this doesn't succeed. This outputs error messages like: MSI (s) (C4:5C) [10:47:54:280]: Invoking remote custom action. DLL: C:\Windows\Installer\MSI37B4.tmp, Entrypoint: RemovePrgFolder CustomAction RemovePrgFolder returned actual error code 1603 (note this may not be 100% accurate if translation happened inside sandbox) Action ended 10:47:54: RemovePrgFolder. Return value 3. Change-Id: I4ce4099eeb3e0ee79eb4a2e1d3887f9810fd9669
-rw-r--r--setup_native/source/win32/customactions/shellextensions/vistaspecial.cxx22
1 files changed, 18 insertions, 4 deletions
diff --git a/setup_native/source/win32/customactions/shellextensions/vistaspecial.cxx b/setup_native/source/win32/customactions/shellextensions/vistaspecial.cxx
index ee4f7dc0df87..73f5f60ddda0 100644
--- a/setup_native/source/win32/customactions/shellextensions/vistaspecial.cxx
+++ b/setup_native/source/win32/customactions/shellextensions/vistaspecial.cxx
@@ -80,6 +80,12 @@ static BOOL RemoveCompleteDirectoryW(const std::wstring& rPath)
return bDirectoryRemoved;
}
+/** Move program folder to program_old. Tries 10 times (program_old1, program_old2, ...).
+ *
+ * @return
+ * ERROR_INSTALL_FAILURE when the folder cannot be moved.
+ * ERROR_SUCCESS otherwise.
+ */
extern "C" __declspec(dllexport) UINT __stdcall RenamePrgFolder( MSIHANDLE handle )
{
std::wstring sOfficeInstallPath = GetMsiPropertyW(handle, L"INSTALLLOCATION");
@@ -101,22 +107,30 @@ extern "C" __declspec(dllexport) UINT __stdcall RenamePrgFolder( MSIHANDLE handl
}
}
- // ? This succeeds unconditionally, even if bSuccess is false!
- return ERROR_SUCCESS;
+ return bSuccess ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE;
}
+
+/** Remove leftover program_old folder(s).
+ *
+ * @return
+ * ERROR_INSTALL_FAILURE when the folder cannot be removed.
+ * ERROR_SUCCESS otherwise.
+ */
extern "C" __declspec(dllexport) UINT __stdcall RemovePrgFolder( MSIHANDLE handle )
{
std::wstring sOfficeInstallPath = GetMsiPropertyW(handle, L"INSTALLLOCATION");
std::wstring sRemoveDir = sOfficeInstallPath + L"program_old";
- RemoveCompleteDirectoryW( sRemoveDir );
+ if (!RemoveCompleteDirectoryW(sRemoveDir))
+ return ERROR_INSTALL_FAILURE;
WCHAR sAppend[2] = L"0";
for ( int i = 0; i < 10; i++ )
{
sRemoveDir = sOfficeInstallPath + L"program_old" + sAppend;
- RemoveCompleteDirectoryW( sRemoveDir );
+ if (!RemoveCompleteDirectoryW( sRemoveDir ))
+ return ERROR_INSTALL_FAILURE;
sAppend[0] += 1;
}