@echo off
if NOT %0==remove goto currentdir
if "%1"=="" goto usage
if "%1"=="-?" goto usage
if "%1"=="/?" goto usage
if NOT "%2"=="" goto tomanyparam

if EXIST %1\doom.exe goto dodoom
if EXIST %1\doom2.exe goto dodoom
if EXIST %1\duke3d.exe goto doduke

echo Could not find doom.exe, doom2.exe, or duke3d.exe in the specified
echo directory.  GamePhones removal aborted.
goto done

:dodoom
if NOT EXIST %1\sersetup.bak goto nodoom
if EXIST %1\sersetup.exe del %1\sersetup.exe
if EXIST %1\sersetup.cfg del %1\sersetup.cfg
if EXIST %1\allmodem.str del %1\allmodem.str
copy %1\sersetup.bak %1\sersetup.exe
del %1\sersetup.bak
echo GamePhones successfully removed from %1!
goto done

:nodoom
echo No sersetup.bak file exists in the specified directory.
echo Either GamePhones has not been installed or it has already been removed.
echo GamePhones removal aborted.
goto done

:doduke
if NOT EXIST %1\commit3d.exe goto noduke
if EXIST %1\commit.exe del %1\commit.exe
if EXIST %1\commit.set del %1\commit.set
if EXIST %1\allmodem.str del %1\allmodem.str
copy %1\commit3d.exe %1\commit.exe
del %1\commit3d.exe
echo GamePhones successfully removed from %1!
goto done

:noduke
echo No commit3d.exe file exists in the specified directory.
echo Either GamePhones has not been installed or it has already been removed.
echo GamePhones removal aborted.
goto done

:tomanyparam
echo To many parameters.
goto usage

:currentdir
echo You must run remove from inside its own directory.

:usage
echo usage: remove thefullpathtothegamedirectory  ex: remove c:\duke3d

:done

