@echo off

    REM *************************************************
    REM *            SPATCH.BAT                         *
    REM *   Patch to allow swapfile.exe to work with    *
    REM *   msdos 6. Designed to be used only once      *
    REM *   for this specific purpose                   *
    REM *************************************************

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

set FNAME=%1
if not exist %FNAME% goto ERROR1
attrib -r -h -s %FNAME%

echo                             NOTE
echo;
echo This batch program modifies your Windows 3.0 SWAPFILE.EXE file for
echo use with MS-DOS 6. A backup of the file will be saved as SWAPFILE.SAV
echo;
echo;

pause

set ADDR=2df2


copy   %FNAME%  swapfile.sav
copy   %FNAME%  swapfile.dbg

echo n swapfile.dbg      > spatch.src
echo l                  >> spatch.src
echo e %ADDR% b8,5,0,90 >> spatch.src
echo w                  >> spatch.src
echo q                  >> spatch.src

debug swapfile.dbg       < spatch.src > NUL
if errorlevel goto error3

copy  swapfile.dbg  %FNAME%
del   swapfile.dbg
goto success

:USAGE

    echo;
    echo USAGE: spatch c:\windows\system\swapfile.exe
    echo;
    echo NOTE: Make sure you use the correct path for swapfile.exe
    echo;

goto end

:ERROR1

   echo;
   echo Can not find the file. Make sure you enter
   echo the correct path and filename.
   echo;

goto end

:ERROR3

   echo Error patching swapfile.exe. Original swapfile.exe being restored.
   echo Look at the readme file to answer any questions.
   echo;

copy swapfile.sav %FNAME%
del  swapfile.sav

goto end

:SUCCESS
   echo;
   echo Your SWAPFILE.EXE file was modified successfully. After you confirm
   echo that the file works correctly, you can delete SWAPFILE.SAV.
   echo;

if exist spatch.src del spatch.src

:END

set ADDR=
set FNAME=
