From e948c5e0a35bf1c076a730b3b1cfbc7460103f65 Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Sun, 29 Aug 2021 14:24:50 +0200 Subject: Windows MSI: Don't reboot if /norestart is specified (which is equivalent to REBOOT=REALLYSUPPRESS) --- src/SetupDLL/Setup.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'src/SetupDLL') diff --git a/src/SetupDLL/Setup.c b/src/SetupDLL/Setup.c index 14bdefd4..570af5d5 100644 --- a/src/SetupDLL/Setup.c +++ b/src/SetupDLL/Setup.c @@ -3472,6 +3472,7 @@ EXTERN_C UINT STDAPICALLTYPE VC_CustomAction_DoChecks(MSIHANDLE hInstaller) DWORD dw = 0; std::wstring szInstallDir = L""; BOOL bRefreshExts = FALSE; + BOOL bDisableReboot = FALSE; UINT uiRet = ERROR_INSTALL_FAILURE; MSILog(hInstaller, MSI_INFO_LEVEL, L"Begin VC_CustomAction_DoChecks"); @@ -3506,6 +3507,22 @@ EXTERN_C UINT STDAPICALLTYPE VC_CustomAction_DoChecks(MSIHANDLE hInstaller) } } + // Get REBOOT to see whether it specified "ReallySuppress" which means no automatic reboot + szValueBuf.clear(); + cchValueBuf = 0; + uiStat = MsiGetProperty(hInstaller, TEXT("REBOOT"), (LPWSTR)TEXT(""), &cchValueBuf); + if (ERROR_MORE_DATA == uiStat) + { + ++cchValueBuf; // add 1 for null termination + szValueBuf.resize(cchValueBuf); + uiStat = MsiGetProperty(hInstaller, TEXT("REBOOT"), &szValueBuf[0], &cchValueBuf); + if ((ERROR_SUCCESS == uiStat)) + { + MSILog(hInstaller, MSI_INFO_LEVEL, L"VC_CustomAction_DoChecks: REBOOT = '%s'", szValueBuf.c_str()); + bDisableReboot = (szValueBuf[0] == L'R' || szValueBuf[0] == L'r'); + } + } + // Read RegKeys previously setup by Pre/Post-Install if (RegOpenKeyExW (HKEY_LOCAL_MACHINE, L"Software\\.VeraCrypt\\Values", 0, KEY_READ, &hkey) == ERROR_SUCCESS) { @@ -3585,8 +3602,16 @@ EXTERN_C UINT STDAPICALLTYPE VC_CustomAction_DoChecks(MSIHANDLE hInstaller) // Check if reboot was required by the pre/post-install and set Wix property ISREBOOTREQUIRED accordingly. if (bRestartRequired) - { - uiRet = MsiSetProperty(hInstaller, L"ISREBOOTREQUIRED", L"1"); + { + if (bDisableReboot) + { + MSILog(hInstaller, MSI_INFO_LEVEL, L"VC_CustomAction_DoChecks: reboot is required but it is disabled because \"REBOOT\" specifies ReallySuppress"); + } + else + { + MSILog(hInstaller, MSI_INFO_LEVEL, L"VC_CustomAction_DoChecks: reboot is required"); + uiRet = MsiSetProperty(hInstaller, L"ISREBOOTREQUIRED", L"1"); + } } else { -- cgit v1.2.3