Verify Files Based on MD5 Hash in WinPE

email me

@echo off
color 0c
title Imaging Compliance Tool

REM ADD FILE CRCs HERE using MD5deep64
REM USAGE IS – MD5 BOOT.WIM
REM USAGE IS – MD5 IMAGE.WIM

set BOOTWIM=497d8fc41a3c40b0a70f22a4f0e22f1a
set IMGWIM=d769b380931ec91eb1588bb260e57131

REM THIS WILL BE A HIDDEN DIAGNOSTIC WINDOW – ALT-TAB to get to Window
rem DO NOT EDIT BELOW THIS LINE
rem —————————————————————
cls
echo Verify imaging files and integrity
echo.

rem check to make sure files exist

color 0c

echo Searching for imaging files:
echo.
if not exist f:\boot\wim\boot.wim (
echo The Boot.wim file is missing! Setup will exit.
f:\boot\apps\ping.exe -n 10 127.0.0.1>nul
echo boot.wim could not be found>>f:\boot\wim\error.log
f:\boot\apps\taskkill.exe /f /im cmd.exe
)
echo Boot.wim found!
f:\boot\apps\ping.exe -n 2 127.0.0.1>nul

if not exist f:\boot\wim\image.wim (
echo The Image.wim file is missing! Setup will exit.
f:\boot\apps\ping.exe -n 10 127.0.0.1>nul
echo image.wim could not be found>>f:\boot\wim\error.log
f:\boot\apps\taskkill.exe /f /im cmd.exe
)
echo Image.wim found!
f:\boot\apps\ping.exe -n 2 127.0.0.1>nul

if not exist f:\boot\wim\imagex.exe (
echo The ImageX.exe file is missing! Setup will exit.
f:\boot\apps\ping.exe -n 10 127.0.0.1>nul
echo imagex.exe could not be found>>f:\boot\wim\error.log
f:\boot\apps\taskkill.exe /f /im cmd.exe
)
echo ImageX.exe found!
f:\boot\apps\ping.exe -n 2 127.0.0.1>nul

if not exist f:\boot\wim\disk.txt (
echo The Disk.txt file is missing! Setup will exit.
f:\boot\apps\ping.exe -n 10 127.0.0.1>nul
echo disk.txt could not be found>>f:\boot\wim\error.log
f:\boot\apps\taskkill.exe /f /im cmd.exe
)
echo Disk.txt found!
f:\boot\apps\ping.exe -n 2 127.0.0.1>nul

echo.
echo.
echo CRC validation – This process may take up to 5 minutes.
echo.
echo Performing Boot.wim CRC check…
echo.
f:\boot\apps\ping.exe -n 2 127.0.0.1>nul

FOR /F “tokens=1 delims=%%i in (‘f:\boot\wim\md5 f:\boot\wim\boot.wim’) do set strBoot=%%i
echo Boot.wim is
echo %strBoot%
f:\boot\apps\ping.exe -n 2 127.0.0.1>nul
echo.
echo CRC is
echo %BOOTWIM%
f:\boot\apps\ping.exe -n 2 127.0.0.1>nul
echo.
if %strBoot% EQU %BOOTWIM% (
echo Boot.wim verified!
echo.
f:\boot\apps\ping.exe -n 2 127.0.0.1>nul
)
if %strBoot% NEQ %BOOTWIM% (
echo Boot.wim failed CRC check! Setup will exit.
f:\boot\apps\ping.exe -n 10 127.0.0.1>nul
echo boot.wim failed crc>>f:\boot\wim\error.log
f:\boot\apps\taskkill.exe /f /im cmd.exe
)

echo.
echo.

echo Performing Image.wim CRC check…
f:\boot\apps\ping.exe -n 2 127.0.0.1>nul

FOR /F “tokens=1 delims=%%j in (‘f:\boot\wim\md5 f:\boot\wim\image.wim’) do set strIMG=%%j
echo Image.wim is
echo %strIMG%
f:\boot\apps\ping.exe -n 2 127.0.0.1>nul
echo.
echo CRC is
echo %IMGWIM%
f:\boot\apps\ping.exe -n 2 127.0.0.1>nul
echo.
if %strIMG% EQU %IMGWIM% (
echo Image.wim verified!
echo.
f:\boot\apps\ping.exe -n 2 127.0.0.1>nul
)
if %strIMG% NEQ %IMGWIM% (
echo Image.wim failed CRC check! Setup will exit.
f:\boot\apps\ping.exe -n 10 127.0.0.1>nul
echo image.wim failed crc>>f:\boot\wim\error.log
f:\boot\apps\taskkill.exe /f /im cmd.exe
)
echo.
echo.

echo Compliance check complete!
rem continue the imaging process
f:\boot\apps\ping.exe -n 4 127.0.0.1>nul

color 0a