Windows MSI: Don't reboot if /norestart is specified (which is equivalent to REBOOT=REALLYSUPPRESS)

This commit is contained in:
Mounir IDRASSI 2021-08-29 14:24:50 +02:00
parent aab6feabaa
commit e948c5e0a3
No known key found for this signature in database
GPG Key ID: 02C30AE90FAE4A6F
1 changed files with 27 additions and 2 deletions

View File

@ -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
{