BIOS check fix, parallel downloads, shopfloor hardening
- Fix check-bios.cmd: replace parenthesized if blocks with goto labels (cmd.exe fails silently with if/else on network-mapped drives) - Move BIOS check files to winpeapps/_shared/BIOS for reliable SMB access - Add network wait loop before BIOS check in startnet.cmd - Show firmware status in WinPE menu header (BIOS_STATUS variable) - Add BypassNRO registry key to skip OOBE network requirement - Refactor download-drivers.py with --parallel N flag (ThreadPoolExecutor) - Set SupportUser AutoLogonCount to 3 in shopfloor unattend - Add shutdown -a at start + shutdown /r /t 10 at end of Run-ShopfloorSetup.ps1 - Switch download-drivers.py from wget to curl for reliable stall detection Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
148
playbook/check-bios.cmd
Normal file
148
playbook/check-bios.cmd
Normal file
@@ -0,0 +1,148 @@
|
||||
@echo off
|
||||
REM check-bios.cmd - Check and apply Dell BIOS update from WinPE x64
|
||||
REM Sets BIOS_STATUS for startnet.cmd menu display
|
||||
|
||||
set "BIOSDIR=%~dp0"
|
||||
set "FLASH=%BIOSDIR%Flash64W.exe"
|
||||
set "MANIFEST=%BIOSDIR%models.txt"
|
||||
|
||||
if exist "%FLASH%" goto :flash_ok
|
||||
echo Flash64W.exe not found, skipping BIOS check.
|
||||
set "BIOS_STATUS=Skipped (Flash64W.exe missing)"
|
||||
exit /b 0
|
||||
|
||||
:flash_ok
|
||||
if exist "%MANIFEST%" goto :manifest_ok
|
||||
echo models.txt not found, skipping BIOS check.
|
||||
set "BIOS_STATUS=Skipped (models.txt missing)"
|
||||
exit /b 0
|
||||
|
||||
:manifest_ok
|
||||
REM --- Get system model from WMI ---
|
||||
set SYSMODEL=
|
||||
for /f "skip=1 tokens=*" %%M in ('wmic csproduct get name 2^>NUL') do (
|
||||
if not defined SYSMODEL set "SYSMODEL=%%M"
|
||||
)
|
||||
for /f "tokens=*" %%a in ("%SYSMODEL%") do set "SYSMODEL=%%a"
|
||||
|
||||
if "%SYSMODEL%"=="" goto :no_model
|
||||
goto :got_model
|
||||
|
||||
:no_model
|
||||
echo Could not detect system model, skipping BIOS check.
|
||||
set "BIOS_STATUS=Skipped (model not detected)"
|
||||
exit /b 0
|
||||
|
||||
:got_model
|
||||
echo Model: %SYSMODEL%
|
||||
|
||||
REM --- Get current BIOS version ---
|
||||
set BIOSVER=
|
||||
for /f "skip=1 tokens=*" %%V in ('wmic bios get smbiosbiosversion 2^>NUL') do (
|
||||
if not defined BIOSVER set "BIOSVER=%%V"
|
||||
)
|
||||
for /f "tokens=*" %%a in ("%BIOSVER%") do set "BIOSVER=%%a"
|
||||
echo Current BIOS: %BIOSVER%
|
||||
|
||||
REM --- Read manifest and find matching BIOS file ---
|
||||
set BIOSFILE=
|
||||
set TARGETVER=
|
||||
for /f "usebackq eol=# tokens=1,2,3 delims=|" %%A in ("%MANIFEST%") do (
|
||||
echo "%SYSMODEL%" | find /I "%%A" >NUL
|
||||
if not errorlevel 1 (
|
||||
set "BIOSFILE=%%B"
|
||||
set "TARGETVER=%%C"
|
||||
goto :found_bios
|
||||
)
|
||||
)
|
||||
|
||||
echo No BIOS update available for this model.
|
||||
set "BIOS_STATUS=%SYSMODEL% - no update in catalog"
|
||||
exit /b 0
|
||||
|
||||
:found_bios
|
||||
if not exist "%BIOSDIR%%BIOSFILE%" goto :bios_file_missing
|
||||
goto :bios_file_ok
|
||||
|
||||
:bios_file_missing
|
||||
echo WARNING: %BIOSFILE% not found in BIOS folder.
|
||||
set "BIOS_STATUS=%SYSMODEL% - %BIOSFILE% missing"
|
||||
exit /b 0
|
||||
|
||||
:bios_file_ok
|
||||
REM --- Skip if already at target version ---
|
||||
echo.%BIOSVER%| find /I "%TARGETVER%" >NUL
|
||||
if not errorlevel 1 goto :already_current
|
||||
|
||||
REM --- Compare versions to prevent downgrade ---
|
||||
call :compare_versions "%BIOSVER%" "%TARGETVER%"
|
||||
if "%VERCMP%"=="newer" goto :already_newer
|
||||
goto :do_flash
|
||||
|
||||
:already_current
|
||||
echo BIOS is already up to date - %TARGETVER%
|
||||
set "BIOS_STATUS=%SYSMODEL% v%BIOSVER% (up to date)"
|
||||
exit /b 0
|
||||
|
||||
:already_newer
|
||||
echo Current BIOS %BIOSVER% is newer than target %TARGETVER% - skipping.
|
||||
set "BIOS_STATUS=%SYSMODEL% v%BIOSVER% (up to date)"
|
||||
exit /b 0
|
||||
|
||||
:do_flash
|
||||
echo Update: %BIOSVER% -^> %TARGETVER%
|
||||
echo Applying BIOS update (this may take a few minutes, do not power off)...
|
||||
|
||||
pushd "%BIOSDIR%"
|
||||
Flash64W.exe /b="%BIOSFILE%" /s /f /l=X:\bios-update.log
|
||||
set FLASHRC=%ERRORLEVEL%
|
||||
popd
|
||||
echo Flash complete (exit code %FLASHRC%).
|
||||
|
||||
if "%FLASHRC%"=="3" goto :already_current
|
||||
if "%FLASHRC%"=="0" goto :flash_done
|
||||
if "%FLASHRC%"=="2" goto :staged
|
||||
if "%FLASHRC%"=="6" goto :staged
|
||||
|
||||
echo WARNING: Flash64W.exe returned unexpected code %FLASHRC%.
|
||||
set "BIOS_STATUS=%SYSMODEL% flash error (code %FLASHRC%)"
|
||||
exit /b 0
|
||||
|
||||
:flash_done
|
||||
echo BIOS update complete.
|
||||
set "BIOS_STATUS=%SYSMODEL% updated %BIOSVER% -^> %TARGETVER%"
|
||||
exit /b 0
|
||||
|
||||
:staged
|
||||
echo.
|
||||
echo ========================================
|
||||
echo BIOS update staged successfully.
|
||||
echo It will flash during POST after the
|
||||
echo post-imaging reboot.
|
||||
echo ========================================
|
||||
echo.
|
||||
set "BIOS_STATUS=%SYSMODEL% STAGED %BIOSVER% -^> %TARGETVER% (flashes on reboot)"
|
||||
exit /b 0
|
||||
|
||||
:compare_versions
|
||||
set "VERCMP=equal"
|
||||
set "_CV=%~1"
|
||||
set "_TV=%~2"
|
||||
for /f "tokens=1,2,3 delims=." %%a in ("%_CV%") do (
|
||||
set /a "C1=%%a" 2>NUL
|
||||
set /a "C2=%%b" 2>NUL
|
||||
set /a "C3=%%c" 2>NUL
|
||||
)
|
||||
for /f "tokens=1,2,3 delims=." %%a in ("%_TV%") do (
|
||||
set /a "T1=%%a" 2>NUL
|
||||
set /a "T2=%%b" 2>NUL
|
||||
set /a "T3=%%c" 2>NUL
|
||||
)
|
||||
if %C1% GTR %T1% ( set "VERCMP=newer" & goto :eof )
|
||||
if %C1% LSS %T1% ( set "VERCMP=older" & goto :eof )
|
||||
if %C2% GTR %T2% ( set "VERCMP=newer" & goto :eof )
|
||||
if %C2% LSS %T2% ( set "VERCMP=older" & goto :eof )
|
||||
if %C3% GTR %T3% ( set "VERCMP=newer" & goto :eof )
|
||||
if %C3% LSS %T3% ( set "VERCMP=older" & goto :eof )
|
||||
set "VERCMP=equal"
|
||||
goto :eof
|
||||
Reference in New Issue
Block a user