It's a little unusual to call again chainloader knowing that it will not function, but if it's working, it's good.
You solved the problem.
Thank you very much.
I updated the script:
!BAT
setlocal
clear
echo Please wait, searching...
find --devices=h > (md)0x220+8
set SKIPPED=0
set N=0
set BDN=-1
######### if the batch was started with /abd as parameter it will not search
######### on boot device (if it's seen as a HDD). Usually is the USB drive (hd0)
if "%1"=="/abd" if "%?_BOOT:~1,2%"=="hd" set BDN=%?_BOOT:~3,1%
:loop
cat --skip=%SKIPPED% --number=1 --locate=" (hd" (md)0x220+8 | set PPOSB=
if "%PPOSB%"=="" goto endloop
set /a SKIPPED=0x%PPOSB%+7 > nul
cat --skip=%SKIPPED% --number=1 --locate=")" (md)0x220+8 | set PPOSE=
if "%PPOSE%"=="" goto endloop
set /a PPOSL=0x%PPOSE%-0x%PPOSB% > nul
set /a SKIPPED=0x%PPOSB%+1 > nul
cat --skip=%SKIPPED% --length=%PPOSL% --locate=" " (md)0x220+8 && set /a SKIPPED=0x%PPOSB%+7 > nul && goto :loop
cat --skip=%SKIPPED% --length=%PPOSL% --locate="," --number=1 (md)0x220+8 | set CPOS=
if "%CPOS%"=="" set /a SKIPPED=0x%PPOSB%+7 > nul && goto :loop
set /a PNL=0x%PPOSE%-0x%CPOS%-1 > nul
set /a SKIPPED=0x%CPOS%+1 > nul
cat --skip=%SKIPPED% --length=%PNL% (md)0x220+8 | set PN=
set /a HDNL=0x%CPOS%-0x%PPOSB%-4 > nul
set /a SKIPPED=0x%PPOSB%+4 > nul
cat --skip=%SKIPPED% --length=%HDNL% (md)0x220+8 | set HDN=
if %PN%>=4 goto :notgood
if %BDN%==%HDN% goto notgood
checkrange 0x06:0x0e parttype (hd%HDN%,%PN%) > nul || goto :notgood
ls (hd%HDN%,%PN%)/ > (md)0x300+8
cat --locate=\0 --number=1 (md)0x300+8 | set ENDFILE=
set /a ENDFILE=0x%ENDFILE% > nul
if not "%ENDFILE%"=="0" write --offset=%ENDFILE% (md)0x300+8 \ \0 > nul
cat --locate=" ntldr " --number=1 (md)0x300+8 > nul || goto :nont
cat --length=0 (hd%HDN%,%PN%)/ntldr | set NTS=
set /a NTS=0x%NTS:~14% > nul
if %NTS%<=74999 goto notgood
set /a N=%N%+1 > nul
set CLCMD=chainloader
if %NTS%>=218976 set OS=XP && goto :esnt
if %NTS%>=185208 set OS=2000 && goto :esnt
set OS=NT
set CLCMD=chainloader --force --load-segment=0x2000
:esnt
if %HDN%==0 set HDNT=first && set HDNTR=USB drive
if %HDN%==1 set HDNT=second && set HDNTR=first internal HDD
if %HDN%==2 set HDNT=third && set HDNTR=second internal HDD
if %HDN%==3 set HDNT=fourth && set HDNTR=third internal HDD
if %HDN%>=4 set HDNT=%HDN%th && set /a HDNN=%HDN%+1 > nul && set HDNTR=%HDN%th internal HDD
if %HDN%==0 set REMAP=
if %HDN%==0 set AFTERR=
if %HDN%>=1 set REMAP=\r\nmap (hd%HDN%) (hd0)\r\nmap (hd0) (hd%HDN%)\r\nmap --rehook
if %HDN%>=1 set AFTERR=\ \&\& boot\r\nmap (hd%HDN%) (hd0)\r\nmap (hd0) (hd%HDN%)\r\nmap --rehook\r\nroot (bd) \> nul\r\n%CLCMD% (hd%HDN%,%PN%)/ntldr
if %PN%==0 set PNT=first
if %PN%==1 set PNT=second
if %PN%==2 set PNT=third
if %PN%==3 set PNT=fourth
set BWINM%N%=title Boot to Windows %OS% on %HDNT% HDD, %PNT% partition\\nUsually the %HDNTR%...%REMAP%\r\nroot (hd0,%PN%) \> nul\r\%CLCMD% /ntldr%AFTERR%
:nont
cat --locate=" bootmgr " --number=1 (md)0x300+8 > nul || goto :nomgr
cat --length=0 (hd%HDN%,%PN%)/bootmgr | set MGRS=
set /a MGRS=0x%MGRS:~14% > nul
if %MGRS%<=199999 goto notgood
if %MGRS%==438840 set OS=Vista && goto :esmgr
if %MGRS%>=390971 set OS=8 && goto :esmgr
if %MGRS%>=358410 set OS=7 && goto :esmgr
set OS=Vista
:esmgr
set /a N=%N%+1 > nul
if %HDN%==0 set HDNT=first && set HDNTR=USB drive
if %HDN%==1 set HDNT=second && set HDNTR=first internal HDD
if %HDN%==2 set HDNT=third && set HDNTR=second internal HDD
if %HDN%==3 set HDNT=fourth && set HDNTR=third internal HDD
if %HDN%>=4 set HDNT=%HDN%th && set /a HDNN=%HDN%+1 > nul && set HDNTR=%HDN%th internal HDD
if %HDN%==0 set REMAP=
if %HDN%==0 set AFTERR=
if %HDN%>=1 set REMAP=\r\nmap (hd%HDN%) (hd0)\r\nmap (hd0) (hd%HDN%)\r\nmap --rehook
if %HDN%>=1 set AFTERR=\ \&\& boot\r\nmap (hd%HDN%) (hd0)\r\nmap (hd0) (hd%HDN%)\r\nmap --rehook\r\nroot (bd) \> nul\r\nchainloader (hd%HDN%,%PN%)/bootmgr
if %PN%==0 set PNT=first
if %PN%==1 set PNT=second
if %PN%==2 set PNT=third
if %PN%==3 set PNT=fourth
set BWINM%N%=title Boot to Windows %OS% on %HDNT% HDD, %PNT% partition\\nUsually the %HDNTR%...%REMAP%\r\nroot (hd0,%PN%) \> nul\r\nchainloader /bootmgr%AFTERR%
:nomgr
:notgood
set /a SKIPPED=0x%PPOSE%+2 > nul
if %N%>=15 goto :endloop
goto :loop
:endloop
if %N%==0 endlocal && clear && echo No bootable Windows NT/2000/XP/Vista/7/8 partitions found, returning to main menu... && pause --wait=5 && goto :finish
write (md)0x300+10 %BWINM1%\r\n%BWINM2%\r\n%BWINM3%\r\n%BWINM4%\r\n%BWINM5%\r\n%BWINM6%\r\n%BWINM7%\r\n%BWINM8%\r\n%BWINM9%\r\n%BWINM10%\r\n%BWINM11%\r\n%BWINM12%\r\n%BWINM13%\r\n%BWINM14%\r\n%BWINM15%\r\ntitle\r\nroot\r\ntitle Return to main menu...\r\nconfigfile /menu.lst\r\n\0 > nul
endlocal
configfile (md)0x300+10
:finish