Allow burn.runonce with burn.clean.room and create runonce log.
Sean Hall committed
May 3, 2022 at 15:26 UTC
e3671abae2f22c3ad7d205aa743bed73ff55e512
3 files changed
+25
-8
src/burn/engine/core.cpp
+6
-3
@@ -1753,13 +1753,16 @@ extern "C" HRESULT CoreParseCommandLine(
1753
}
1754
else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, BURN_COMMANDLINE_SWITCH_RUNONCE, -1))
1755
{
1756
- if (BURN_MODE_UNKNOWN != pInternalCommand->mode)
1756
+ switch (pInternalCommand->mode)
1757
{
1758
+ case BURN_MODE_UNKNOWN: __fallthrough;
1759
+ case BURN_MODE_NORMAL:
1760
+ pInternalCommand->mode = BURN_MODE_RUNONCE;
1761
+ break;
1762
+ default:
1763
fInvalidCommandLine = TRUE;
1764
TraceLog(E_INVALIDARG, "Multiple mode command-line switches were provided.");
1765
}
1761
-
1762
- pInternalCommand->mode = BURN_MODE_RUNONCE;
1766
}
1767
else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], lstrlenW(BURN_COMMANDLINE_SWITCH_IGNOREDEPENDENCIES), BURN_COMMANDLINE_SWITCH_IGNOREDEPENDENCIES, lstrlenW(BURN_COMMANDLINE_SWITCH_IGNOREDEPENDENCIES)))
1768
{
src/burn/engine/engine.cpp
+8
-4
@@ -33,7 +33,7 @@ static HRESULT RunEmbedded(
33
__in BURN_ENGINE_STATE* pEngineState
34
);
35
static HRESULT RunRunOnce(
36
- __in const BURN_REGISTRATION* pRegistration,
36
+ __in BURN_ENGINE_STATE* pEngineState,
37
__in int nCmdShow
38
);
39
static HRESULT RunApplication(
@@ -221,7 +221,7 @@ extern "C" HRESULT EngineRun(
221
break;
222
223
case BURN_MODE_RUNONCE:
224
- hr = RunRunOnce(&engineState.registration, nCmdShow);
224
+ hr = RunRunOnce(&engineState, nCmdShow);
225
ExitOnFailure(hr, "Failed to run RunOnce mode.");
226
break;
227
@@ -703,7 +703,7 @@ LExit:
703
}
704
705
static HRESULT RunRunOnce(
706
- __in const BURN_REGISTRATION* pRegistration,
706
+ __in BURN_ENGINE_STATE* pEngineState,
707
__in int nCmdShow
708
)
709
{
@@ -712,7 +712,11 @@ static HRESULT RunRunOnce(
712
LPWSTR sczBurnPath = NULL;
713
HANDLE hProcess = NULL;
714
715
- hr = RegistrationGetResumeCommandLine(pRegistration, &sczNewCommandLine);
715
+ // Initialize logging.
716
+ hr = LoggingOpen(&pEngineState->log, &pEngineState->internalCommand, &pEngineState->command, &pEngineState->variables, pEngineState->registration.sczDisplayName);
717
+ ExitOnFailure(hr, "Failed to open run once log.");
718
+
719
+ hr = RegistrationGetResumeCommandLine(&pEngineState->registration, &sczNewCommandLine);
720
ExitOnFailure(hr, "Unable to get resume command line from the registry");
721
722
// and re-launch
src/burn/engine/logging.cpp
+11
-1
@@ -39,7 +39,17 @@ extern "C" HRESULT LoggingOpen(
39
HRESULT hr = S_OK;
40
LPWSTR sczLoggingBaseFolder = NULL;
41
LPWSTR sczPrefixFormatted = NULL;
42
- LPCWSTR wzPostfix = BURN_MODE_UNTRUSTED == pInternalCommand->mode ? L".cleanroom" : NULL;
42
+ LPCWSTR wzPostfix = NULL;
43
+
44
+ switch (pInternalCommand->mode)
45
+ {
46
+ case BURN_MODE_UNTRUSTED:
47
+ wzPostfix = L".cleanroom";
48
+ break;
49
+ case BURN_MODE_RUNONCE:
50
+ wzPostfix = L".runonce";
51
+ break;
52
+ }
53
54
hr = InitializeLogging(pLog, pInternalCommand);
55
ExitOnFailure(hr, "Failed to initialize logging.");