@echo off

echo.
echo ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
echo ³ Convert + datestamp self-extracting file to .zip file, with comment ³
echo ³ By Prof. Timo Salmi, ts@chyde.uwasa.fi, Sun 30-Aug-1992             ³
echo ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
echo.

rem You need help :-)
if "%1"=="" goto _help

rem Check that wilrcards have not been used
for %%f in (%1) do if "%1"=="%%f" goto :_testext
echo No wildcards allowed in the file name %1
goto _out

rem Check that no extension was used
:_testext
set _exten=%1
:_nextchar
set _prev=%_exten%
for %%f in (/%_exten%) do set _exten=%%f
if ".%_exten%"=="%_prev%" goto _extfound
if not "%_exten%"=="%_prev%" goto _nextchar
goto _noext

:_extfound
echo No extension allowed in the file name %1
goto _out

:_noext
set _exten=
rem Check for the necessary programs and status
rem You'' have to customize these
if not exist %1.exe goto _notfound
if not exist e:\arczip\comment.txt goto _nocomment
if not exist c:\tools\scan.exe goto _noscan
if not exist c:\tools\pkzip.exe goto _nopkzip
if not exist r:\nul goto _no_r
if exist r:\tmp$$$\*.* goto _notempty

rem Convert (I have r: as ramdisk, customize as applicable)
r:
if not exist r:\tmp$$$\nul mkdir r:\tmp$$$
cd \tmp$$$
r:\%1
if not exist r:\tmp$$$\*.* goto _notsfx
c:\tools\scan /m /nomem r:\tmp$$$
if errorlevel==1 goto _virus
pkzip -mu -o -z r:\%1 *.* < e:\arczip\comment.txt
cd \
rmdir r:\tmp$$$
goto _out

:_notfound
echo File %1.exe not found
goto _out

:_nocomment
echo File e:\arczip\comment.txt not found
echo You'll have to customize the batch or omit this feature
goto _out

:_noscan
echo File c:\tools\scan.exe not found
echo You'll have to adjust for your own configuration
goto _out

:_nopkzip
echo File c:\tools\pkzip.exe not found
echo You'll have to adjust for your own configuration
goto _out

:_no_r
echo No R: drive
echo Customize the batch or create one with SUBST
goto _out

:_notempty
echo Directory r:\tmp$$$ not empty
goto _out

:_notsfx
echo File %1.exe is not self-extracting
cd \
rmdir r:\tmp$$$
goto _out

:_virus
echo Virus warning
cd \
goto _out

:_help
echo Usage: EXE2ZIP FileName  (No path, no extension)

:_out
echo on
