@echo off
if %1.==?. goto helpxmsdsk
if %1.==/?. goto helpxmsdsk
if %1.==/u. goto uninst
if %2.==/u. goto uninst
if %3.==/u. goto uninst
if %4.==/u. goto uninst
if %5.==/u. goto uninst
if %6.==/u. goto uninst
:if not %xmsdisk%.==. and if %1.==. goto info
if %1.==. %0 32768 /y /t
if %1.==/y. goto helpxmsdsk
if not %2.==/y. goto helpxmsdsk
if %3.==/y. goto helpxmsdsk
if %4.==/y. goto helpxmsdsk
set xmsdsize=%1
xmsdsk %1 %2 %3 %4 %5 %6
rem if %xmsdisk%.==. xmsdsk 4096 /y
rem if not %1.==. xmsdsk %1 %2 %3 %4 %5 %6
if errorlevel 13 goto drivem
if errorlevel 12 goto drivel
if errorlevel 11 goto drivek
if errorlevel 10 goto drivej
if errorlevel 9 goto drivei
if errorlevel 8 goto driveh
if errorlevel 7 goto driveg
if errorlevel 6 goto drivef
if errorlevel 5 goto drivee
if errorlevel 4 goto drived
if errorlevel 3 goto drivec
if errorlevel 2 goto driveb
if errorlevel 0 goto noxmsdisk

:drivem
set xmsdrive=M
goto setpath

:drivel
set xmsdrive=L
goto setpath

:drivek
set xmsdrive=K
goto setpath

:drivej
set xmsdrive=J
goto setpath

:drivei
set xmsdrive=I
goto setpath

:driveh
set xmsdrive=H
goto setpath

:driveg
set xmsdrive=G
goto setpath

:drivef
set xmsdrive=F
goto setpath

:drivee
set xmsdrive=E
goto setpath

:drived
set xmsdrive=D
goto setpath

:drivec
set xmsdrive=C
goto setpath

:driveb
set xmsdrive=B
goto setpath

:error
echo.
echo            XMSDSK not loaded, load first.
echo.
goto end

:errorunload
echo.
echo        Error unloading XMSDSK.
echo.
goto end

:helpxmsdsk
xmsdsk /?
goto end

:noxmsdisk
echo    Nothing done.
goto end

:setpath
set xmsdisk=%xmsdrive%:
echo    XMSDISK is Drive %xmsdisk% with %xmsdsize% KB.
echo.
set xmsdisk=%xmsdisk%\
if %xmsdpath%.==. set xmsdpath=%path%
for %%a in (%path%) do if %%a.==%xmsdisk%. goto skipsetpath
path %path%;%xmsdisk%
:skipsetpath
goto settemp

:settemp
md %xmsdisk%temp
if exist %xmsdisk%temp\nul set tmp=%xmsdisk%TEMP
set temp=%tmp%
:call settempe
:chkdsk 

goto end

:uninst
if %xmsdisk%.==. goto error
xmsdsk /u /y
if errorlevel 1 goto errorunload
if errorlevel 0 echo    XMSDSK unloaded.
set xmsdisk=
set xmsdrive=
set xmsdsize=
set path=%xmsdpath%
set xmsdpath=
call settempe
goto end
:end
