@@ -64,7 +64,7 @@ static HRESULT EnsureRegistrationVariable(
6464 );
6565static HRESULT UpdateResumeMode (
6666 __in BURN_REGISTRATION* pRegistration,
67- __in HKEY hkRegistration,
67+ __in_opt HKEY hkRegistration,
6868 __in BURN_RESUME_MODE resumeMode,
6969 __in BOOTSTRAPPER_REGISTRATION_TYPE registrationType,
7070 __in BOOL fRestartInitiated
@@ -461,13 +461,7 @@ extern "C" HRESULT RegistrationSetDynamicVariables(
461461 )
462462{
463463 HRESULT hr = S_OK;
464- LONGLONG llInstalled = 0 ;
465-
466- // Detect if bundle is already installed.
467- hr = RegistrationDetectInstalled (pRegistration);
468- ExitOnFailure (hr, " Failed to detect bundle install state." );
469-
470- llInstalled = BOOTSTRAPPER_REGISTRATION_TYPE_FULL == pRegistration->detectedRegistrationType ? 1 : 0 ;
464+ LONGLONG llInstalled = BOOTSTRAPPER_REGISTRATION_TYPE_FULL == pRegistration->detectedRegistrationType ? 1 : 0 ;
471465
472466 hr = VariableSetNumeric (pVariables, BURN_BUNDLE_INSTALLED, llInstalled, TRUE );
473467 ExitOnFailure (hr, " Failed to set the bundle installed built-in variable." );
@@ -483,7 +477,8 @@ extern "C" HRESULT RegistrationSetDynamicVariables(
483477}
484478
485479extern " C" HRESULT RegistrationDetectInstalled (
486- __in BURN_REGISTRATION* pRegistration
480+ __in BURN_REGISTRATION* pRegistration,
481+ __in BURN_CACHE* pCache
487482)
488483{
489484 HRESULT hr = S_OK;
@@ -496,14 +491,28 @@ extern "C" HRESULT RegistrationDetectInstalled(
496491 {
497492 // For PUOM/PMOU bundles, check per-machine then fall back to per-user.
498493 hr = DetectInstalled (pRegistration, HKEY_LOCAL_MACHINE);
494+ if (SUCCEEDED (hr))
495+ {
496+ pRegistration->fPerMachine = TRUE ;
499497
500- if (FAILED (hr))
498+ hr = RegistrationSetPaths (pRegistration, pCache);
499+ ExitOnFailure (hr, " Failed to set registration paths for per-machine configurable scope." );
500+ }
501+ else
501502 {
502503 hr = DetectInstalled (pRegistration, HKEY_CURRENT_USER);
504+
505+ if (SUCCEEDED (hr))
506+ {
507+ pRegistration->fPerMachine = FALSE ;
508+
509+ hr = RegistrationSetPaths (pRegistration, pCache);
510+ ExitOnFailure (hr, " Failed to set registration paths for per-user configurable scope." );
511+ }
503512 }
504513 }
505514
506- // LExit:
515+ LExit:
507516 // Not finding the key or value is okay.
508517 if (E_FILENOTFOUND == hr || E_PATHNOTFOUND == hr)
509518 {
@@ -1086,6 +1095,8 @@ extern "C" HRESULT RegistrationSetPaths(
10861095 hr = PathConcatRelativeToFullyQualifiedBase (sczCacheDirectory, pRegistration->sczExecutableName , &pRegistration->sczCacheExecutablePath );
10871096 ExitOnFailure (hr, " Failed to build cached executable path." );
10881097
1098+ pRegistration->fCached = pRegistration->sczCacheExecutablePath && FileExistsEx (pRegistration->sczCacheExecutablePath , NULL );
1099+
10891100 // build state file path
10901101 hr = StrAllocFormatted (&pRegistration->sczStateFile , L" %ls\\ state.rsm" , sczCacheDirectory);
10911102 ExitOnFailure (hr, " Failed to build state file path." );
@@ -1242,7 +1253,7 @@ static HRESULT EnsureRegistrationVariable(
12421253
12431254static HRESULT UpdateResumeMode (
12441255 __in BURN_REGISTRATION* pRegistration,
1245- __in HKEY hkRegistration,
1256+ __in_opt HKEY hkRegistration,
12461257 __in BURN_RESUME_MODE resumeMode,
12471258 __in BOOTSTRAPPER_REGISTRATION_TYPE registrationType,
12481259 __in BOOL fRestartInitiated
@@ -1254,7 +1265,7 @@ static HRESULT UpdateResumeMode(
12541265 LPWSTR sczRunOnceCommandLine = NULL ;
12551266 LPCWSTR sczResumeKey = REGISTRY_RUN_ONCE_KEY;
12561267
1257- LogId (REPORT_STANDARD, MSG_SESSION_UPDATE, pRegistration->sczRegistrationKey , LoggingInstallScopeToString (pRegistration->fPerMachine ), LoggingResumeModeToString (resumeMode), LoggingBoolToString (fRestartInitiated ), LoggingBoolToString (pRegistration->fDisableResume ));
1268+ LogId (REPORT_STANDARD, MSG_SESSION_UPDATE, pRegistration->sczRegistrationKey , LoggingInstallScopeToString (pRegistration->fPerMachine ), LoggingResumeModeToString (resumeMode), LoggingBoolToString (fRestartInitiated ), LoggingBoolToString (pRegistration->fDisableResume ), LoggingRegistrationTypeToString (registrationType) );
12581269
12591270 // write resume information
12601271 if (hkRegistration)
@@ -1776,7 +1787,6 @@ static HRESULT DetectInstalled(
17761787 DWORD dwInstalled = 0 ;
17771788 DWORD dwScope = 0 ;
17781789
1779- pRegistration->fCached = pRegistration->sczCacheExecutablePath && FileExistsEx (pRegistration->sczCacheExecutablePath , NULL );
17801790 pRegistration->detectedRegistrationType = BOOTSTRAPPER_REGISTRATION_TYPE_NONE;
17811791 pRegistration->detectedScope = BOOTSTRAPPER_SCOPE_DEFAULT;
17821792
0 commit comments