@echo off
echo.
echo Preparing the DFSee console, command winow ...
rem 23-11-2005 JvW Added usage and made CMD/BAT indentical
rem 09-08-2016 JvW Use 'dfsrunas.exe' to elevate Windows to admin, ignoring explicit window sizes

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
if "%OS%"=="FREEDOS" goto notnt

ver | findstr /i /C:"XP [" > nul
if %errorlevel% EQU 0 goto winxpnt
ver | findstr /i /C:"Version 5" > nul
if %errorlevel% EQU 0 goto winxpnt
ver | findstr /i /C:"NT [" > nul
if %errorlevel% EQU 0 goto winxpnt
ver | findstr /i /C:"Version 4" > nul
if %errorlevel% EQU 0 goto winxpnt

set dfsexe=dfsrunas -c dfswin.exe
set dfsmode=no
goto dfsee

:winxpnt
set dfsexe=dfswin.exe
goto dfsee

:notnt
set dfsexe=dfsdos.exe

:dfsee

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

if "%dfsmode%"=="no" goto work
if "%2"==""  goto standard
if "%2"=="." goto standard
mode %1,%2
goto work

:usage
echo.
if "%dfsmode%"=="no" goto nomode
echo Usage:  %0  #columns #rows [other %dfsexe% parameters]
goto moreuse
:nomode
echo Usage:  %0  [%dfsexe% parameters]
echo.
echo Note: Window size will be set by DFSee, when needed
:moreuse
echo.
echo   Check other DFSee parameters using: %dfsexe% -?
echo.
goto end

:standard
mode 84,30
:work
%dfsexe% %3 %4 %5 %6 %7 %8 %9

:end
