startnet.cmd: fix BIOS sub-stage detection (substring-replace trick)
Original used 'echo %BIOS_STATUS% | findstr /C:"->"' to detect whether check-bios.cmd actually applied a firmware update. The '>' inside the value (from check-bios writing e.g. 'updated 1.5.0 -> 1.6.0') gets parsed by cmd.exe as a redirect operator BEFORE the pipe is set up. Result: echo wrote a file named '1.6.0' in cwd instead of piping to findstr. findstr saw no input, returned errorlevel=1, block never fired. Plus a stray file got created in X:\Windows\System32. Confirmed empirically in the win11 VM with test bat: - echo|findstr approach: SKIPS even when '->' present (bug) - substring-replace: FIRES iff '->' present (correct) Fix: replace echo/pipe/findstr with a substring-replace test: call set "BIOS_STATUS_STRIPPED=%%BIOS_STATUS:->=%%" if not "%BIOS_STATUS%"=="%BIOS_STATUS_STRIPPED%" ( ... ) The '>' inside %VAR:->=...% is parsed as part of the substring substitution token, not as a redirect. Yields true diff only when the arrow was actually in BIOS_STATUS. xcopy region was never impacted by the bug because subsequent if-exist blocks didn't depend on the previous errorlevel state. But the BIOS sub-stage push to the dashboard was silently broken. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -261,12 +261,18 @@ REM dashboard friendly-label swaps to "Updating BIOS firmware". The "->"
|
||||
REM marker is what check-bios writes for both "updated" and "STAGED"
|
||||
REM cases. No-op states ("up to date", "no update in catalog", "Skipped",
|
||||
REM "missing") never contain the arrow and stay on the default label.
|
||||
echo %BIOS_STATUS% | findstr /C:"->" >NUL
|
||||
if not errorlevel 1 (
|
||||
REM
|
||||
REM CAUTION: cannot use `echo %BIOS_STATUS% | findstr /C:"->"` - the `>`
|
||||
REM inside the value gets parsed as a redirect operator before the pipe,
|
||||
REM breaking the pipeline. Use substring-replace trick: if removing "->"
|
||||
REM from BIOS_STATUS yields a different string, the arrow was present.
|
||||
call set "BIOS_STATUS_STRIPPED=%%BIOS_STATUS:->=%%"
|
||||
if not "%BIOS_STATUS%"=="%BIOS_STATUS_STRIPPED%" (
|
||||
if exist "Y:\scripts\winpe-status-push.ps1" (
|
||||
powershell -NoProfile -ExecutionPolicy Bypass -File "Y:\scripts\winpe-status-push.ps1" -CurrentStage "WinPE: BIOS firmware update - %BIOS_STATUS%"
|
||||
powershell -NoProfile -ExecutionPolicy Bypass -File "Y:\scripts\winpe-status-push.ps1" -CurrentStage "WinPE: BIOS firmware update"
|
||||
)
|
||||
)
|
||||
set "BIOS_STATUS_STRIPPED="
|
||||
|
||||
echo Waiting for PESetup.exe to start...
|
||||
:wait_start
|
||||
|
||||
Reference in New Issue
Block a user