@echo off
rem 15-06-2017 JvW Derived from DFSEDIT, Browse IMZ imagefile, optional file-dialog

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 dfswin.exe
goto dfsee

:winxpnt
set dfsexe=dfswin.exe
goto dfsee

:notnt
set dfsexe=dfsdos.exe
:dfsee
set cmdext=BAT

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

%dfsexe% -l- -Q -d- -w imz %1 %2 %3 %4 %5 %6 %7 %8 %9
goto end

:usage
echo BROWSE an (IMZ compressed) partition or disk image
echo.
echo Usage:  %0  [filename | directory\] [other 'imz' parameters]
echo.
echo      filename     : Name of a file to be edited in binary (HEX/ASCII)
echo.
echo      directory    : Name of a directory to select an IMZ image from
echo.
echo      -e:'ext'     : Overrule default 'imz' extension with 'ext'
echo.
echo      When no filename or directory is specified, a filedialog is
echo      opened for the CURRENT directory.
:end
