Verify Files Based on Size and Date in WinPE

email me

@echo off
color 0c
title Imaging Compliance Tool

rem ADD SIZES OF FILES HERE – DIR FILENAME
set IMGWIM=11261172302
rem add date
set IMGDATE=03/05/2014

rem add size
set BOOTWIM=251636641
rem add date
set BOOTDATE=03/05/2014

cls
echo Used to verify imaging files, sizes, and dates
echo.

rem DO NOT EDIT BELOW THIS LINE
rem —————————————————————
rem check to make sure files exist

echo Searching for imaging files:
echo.
if not exist boot.wim (
echo The Boot.wim file is missing! Setup will exit.
pause
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 image.wim (
echo The Image.wim file is missing! Setup will exit.
pause
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 imagex.exe (
echo The ImageX.exe file is missing! Setup will exit.
pause
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 disk.txt (
echo The Disk.txt file is missing! Setup will exit.
pause
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 Checking Image.wim size…
f:\boot\apps\ping.exe -n 2 127.0.0.1>nul
FOR /F “tokens=4 delims=%%i in (‘dir /-C image.wim ^| find /i “image.wim”‘) do (
echo Image.wim file size: %%i
f:\boot\apps\ping.exe -n 2 127.0.0.1>nul
f:\boot\apps\ping.exe -n 2 127.0.0.1>nul
IF %%i EQU %IMGWIM% (
echo Image.wim verified!: %IMGWIM%
echo SUCCESS!
f:\boot\apps\ping.exe -n 2 127.0.0.1>nul
) ELSE (
echo FAILED. Exiting setup…
pause
f:\boot\apps\taskkill.exe /f /im cmd.exe
)
)

echo.
echo.

echo Checking Image.wim date…
f:\boot\apps\ping.exe -n 2 127.0.0.1>nul
FOR /F “tokens=1 delims=%%k in (‘dir /-C image.wim ^| find /i “image.wim”‘) do (
echo Image.wim file date: %%k
f:\boot\apps\ping.exe -n 2 127.0.0.1>nul

f:\boot\apps\ping.exe -n 2 127.0.0.1>nul
IF %%k EQU %IMGDATE% (
echo Image.wim date verified!: %IMGDATE%
echo SUCCESS!
f:\boot\apps\ping.exe -n 2 127.0.0.1>nul
) ELSE (
echo FAILED. Exiting setup…
pause
f:\boot\apps\taskkill.exe /f /im cmd.exe
)
)

echo.
echo.

echo Checking Boot.wim size…
f:\boot\apps\ping.exe -n 2 127.0.0.1>nul
FOR /F “tokens=4 delims=%%j in (‘dir /-C boot.wim ^| find /i “boot.wim”‘) do (
echo Boot.wim file size: %%j
f:\boot\apps\ping.exe -n 2 127.0.0.1>nul

f:\boot\apps\ping.exe -n 2 127.0.0.1>nul
IF %%j EQU %BOOTWIM% (
echo Boot.wim verified!: %BOOTWIM%
echo SUCCESS!
f:\boot\apps\ping.exe -n 2 127.0.0.1>nul
) ELSE (
echo FAILED. Exiting setup…
pause
f:\boot\apps\taskkill.exe /f /im cmd.exe
)
)

echo.
echo.

echo Checking Boot.wim date…
f:\boot\apps\ping.exe -n 2 127.0.0.1>nul
FOR /F “tokens=1 delims=%%l in (‘dir /-C boot.wim ^| find /i “boot.wim”‘) do (
echo Boot.wim file date: %%l
f:\boot\apps\ping.exe -n 2 127.0.0.1>nul

f:\boot\apps\ping.exe -n 2 127.0.0.1>nul
IF %%l EQU %BOOTDATE% (
echo Boot.wim date verified!: %BOOTDATE%
echo SUCCESS!
f:\boot\apps\ping.exe -n 2 127.0.0.1>nul
) ELSE (
echo FAILED. Exiting setup…
pause
f:\boot\apps\taskkill.exe /f /im cmd.exe
)
)

echo.
echo.

color 0a
pause