@echo off
rem 19-05-2004 JvW Wrapper to check Win BOOT.INI on all partitions   (6.07)
rem 09-08-2016 JvW Use 'dfsrunas.exe' to elevate Windows to admin, ignoring explicit window sizes
echo.
echo Get BOOT.INI information on ALL primary FAT/NTFS partitions

if "%0"=="BINITEST"     echo on
if "%0"=="binitest"     echo on

set logfile=dfsbtini.log

echo DFSee BOOT.INI check on all primary FAT/NTFS partitions > %logfile%
if "%OS2_SHELL%"=="" goto notos2
set dfsexe=dfsos2.exe
set cmdext=CMD
goto dfsee
:notos2
if "%OS%"==""        goto notnt
if "%OS%"=="DOS"     goto notnt
if "%OS%"=="MSDOS"   goto notnt
if "%OS%"=="DRDOS"   goto notnt
if "%OS%"=="IBMDOS"  goto notnt
if "%OS%"=="OPENDOS" goto notnt
set dfsexe=dfsrunas dfswin.exe
set cmdext=BAT
goto dfsee
:notnt
set dos=yes
set dfsexe=dfsdos.exe
set cmdext=BAT
:dfsee

echo.
if "%1" == "?"   goto usage
if "%1" == "/?"  goto usage
if "%1" == "-?"  goto usage

%dfsexe% -l:%logfile% -b -q query RValid
if not errorlevel 1 goto work
echo.
echo NOTE: Your DFSee version is not properly registred, this will cause
echo       some extra delays and reminder messages to be displayed  ...
echo.

:work

%dfsexe% -l:%logfile% -b -q -Q -B- part -r -s

set part10=1 2 3 4 5 6 7 8 9 10
set part20=%part10% 11 12 13 14 15 16 17 18 19 20
set part30=%part20% 21 22 23 24 25 26 27 28 29 30
set part40=%part30% 31 32 33 34 35 36 37 38 39 40

echo Checking number of partitions to check ...
%dfsexe% -l:%logfile% -b -B- query Partitions
if errorlevel 51 goto partbad

if not errorlevel 40 goto past50
set parts=( %part40% 41 42 43 44 45 46 47 48 49 50 )
goto  check
:past50
if not errorlevel 49 goto past49
set parts=( %part40% 41 42 43 44 45 46 47 48 49 )
goto  check
:past49
if not errorlevel 48 goto past48
set parts=( %part40% 41 42 43 44 45 46 47 48 )
goto  check
:past48
if not errorlevel 47 goto past47
set parts=( %part40% 41 42 43 44 45 46 47 )
goto  check
:past47
if not errorlevel 46 goto past46
set parts=( %part40% 41 42 43 44 45 46 )
goto  check
:past46
if not errorlevel 45 goto past45
set parts=( %part40% 41 42 43 44 45 )
goto  check
:past45
if not errorlevel 44 goto past44
set parts=( %part40% 41 42 43 44 )
goto  check
:past44
if not errorlevel 43 goto past43
set parts=( %part40% 41 42 43 )
goto  check
:past43
if not errorlevel 42 goto past42
set parts=( %part40% 41 42 )
goto  check
:past42
if not errorlevel 41 goto past41
set parts=( %part40% 41 )
goto  check
:past41
if not errorlevel 30 goto past40
set parts=( %part30% 31 32 33 34 35 36 37 38 39 40 )
goto  check
:past40
if not errorlevel 39 goto past39
set parts=( %part30% 31 32 33 34 35 36 37 38 39 )
goto  check
:past39
if not errorlevel 38 goto past38
set parts=( %part30% 31 32 33 34 35 36 37 38 )
goto  check
:past38
if not errorlevel 37 goto past37
set parts=( %part30% 31 32 33 34 35 36 37 )
goto  check
:past37
if not errorlevel 36 goto past36
set parts=( %part30% 31 32 33 34 35 36 )
goto  check
:past36
if not errorlevel 35 goto past35
set parts=( %part30% 31 32 33 34 35 )
goto  check
:past35
if not errorlevel 34 goto past34
set parts=( %part30% 31 32 33 34 )
goto  check
:past34
if not errorlevel 33 goto past33
set parts=( %part30% 31 32 33 )
goto  check
:past33
if not errorlevel 32 goto past32
set parts=( %part30% 31 32 )
goto  check
:past32
if not errorlevel 31 goto past31
set parts=( %part30% 31 )
goto  check
:past31
if not errorlevel 30 goto past30
set parts=( %part20% 21 22 23 24 25 26 27 28 29 30 )
goto  check
:past30
if not errorlevel 29 goto past29
set parts=( %part20% 21 22 23 24 25 26 27 28 29 )
goto  check
:past29
if not errorlevel 28 goto past28
set parts=( %part20% 21 22 23 24 25 26 27 28 )
goto  check
:past28
if not errorlevel 27 goto past27
set parts=( %part20% 21 22 23 24 25 26 27 )
goto  check
:past27
if not errorlevel 26 goto past26
set parts=( %part20% 21 22 23 24 25 26 )
goto  check
:past26
if not errorlevel 25 goto past25
set parts=( %part20% 21 22 23 24 25 )
goto  check
:past25
if not errorlevel 24 goto past24
set parts=( %part20% 21 22 23 24 )
goto  check
:past24
if not errorlevel 23 goto past23
set parts=( %part20% 21 22 23 )
goto  check
:past23
if not errorlevel 22 goto past22
set parts=( %part20% 21 22 )
goto  check
:past22
if not errorlevel 21 goto past21
set parts=( %part20% 21 )
goto  check
:past21
if not errorlevel 20 goto past20
set parts=( %part10% 11 12 13 14 15 16 17 18 19 20 )
goto  check
:past20
if not errorlevel 19 goto past19
set parts=( %part10% 11 12 13 14 15 16 17 18 19 )
goto  check
:past19
if not errorlevel 18 goto past18
set parts=( %part10% 11 12 13 14 15 16 17 18 )
goto  check
:past18
if not errorlevel 17 goto past17
set parts=( %part10% 11 12 13 14 15 16 17 )
goto  check
:past17
if not errorlevel 16 goto past16
set parts=( %part10% 11 12 13 14 15 16 )
goto  check
:past16
if not errorlevel 15 goto past15
set parts=( %part10% 11 12 13 14 15 )
goto  check
:past15
if not errorlevel 14 goto past14
set parts=( %part10% 11 12 13 14 )
goto  check
:past14
if not errorlevel 13 goto past13
set parts=( %part10% 11 12 13 )
goto  check
:past13
if not errorlevel 12 goto past12
set parts=( %part10% 11 12 )
goto  check
:past12
if not errorlevel 11 goto past11
set parts=( %part10% 11 )
goto  check
:past11
if not errorlevel 10 goto past10
set parts=( 1 2 3 4 5 6 7 8 9 10)
goto  check
:past10
if not errorlevel  9 goto past9
set parts=( 1 2 3 4 5 6 7 8 9 )
goto  check
:past9
if not errorlevel  8 goto past8
set parts=( 1 2 3 4 5 6 7 8 )
goto  check
:past8
if not errorlevel  7 goto past7
set parts=( 1 2 3 4 5 6 7 )
goto  check
:past7
if not errorlevel  6 goto past6
set parts=( 1 2 3 4 5 6 )
goto  check
:past6
if not errorlevel  5 goto past5
set parts=( 1 2 3 4 5 )
goto  check
:past5
if not errorlevel  4 goto past4
set parts=( 1 2 3 4 )
goto  check
:past4
if not errorlevel  3 goto past3
set parts=( 1 2 3 )
goto  check
:past3
if not errorlevel  2 goto past2
set parts=( 1 2 )
goto  check
:past2
if not errorlevel  1 goto past1
set parts=( 1 )
goto  check
:past1
goto partbad

:check
echo Start checking BOOT.INI on all primary FAT/NTFS partitions ...
for %%P in %parts% do %dfsexe% -l:%logfile% -b -B- query PBootIni %%P
goto showdir

:partbad
echo.
echo ERROR: The number of partitions is not supported with %0
goto end

:showdir
echo.
echo Resulting DFSee BOOTINI logfile:
dir %logfile%
echo.
goto end

:usage
echo Run a DFSee query PBootini command on every partition, checking the
echo 'default=' line in BOOT.INI on every primary FAT or NTFS partition.
echo.
echo A mismatch, reported as a query-value not equal to ZERO can be
echo corrected using a 'BOOTINI' command, see DFSFAT.TXT and DFSNTFS.TXT
echo.
echo Usage: %0
echo.
echo   The maximum number of partitions checked by %0 is 50,
echo   due to limitations in the BATCH processing language.
echo.
:end
