@echo off
@cls
if %1 !==! goto Usage 
if %1 == /h goto Usage
if %1 == /H goto Usage
if %1 == /? goto Usage
if %2 !==! goto Usage 
if not exist %1\ime\ISWIN.COM goto WrongDrv
@call %1\ime\ISWIN.COM
if ERRORLEVEL 1 goto DosBox
if exist %2\WIN.COM goto ChkUinst

:WrongDir
echo !!! ERROR -- %2 is not the correct Windows Path-Name !!!
goto Usage

:WrongDrv
echo !!! ERROR -- %1 is not the correct Source Driver-Name !!!
goto Usage

:DosBox
echo !!! ERROR -- You can NOT run this batch file in DOS-BOX of Windows !!!
goto Usage

:Usage
echo Purpose  : This program will 
echo            (1) Remove New IME-related files provided by Microsoft Office
echo                Chinese Version
echo            (2) Restore IME-related files come with Microsoft Windows 3.1 
echo                Chinese Version
echo Usage    : RESTIME SourceDir CWIN31Dir
echo Argument : SourceDir is the Driver-Name from there you install New IMEs
echo            CWIN31Dir is the Path-Name of Windows 3.1 Chinese Version
echo Example  : RESTIME A: C:\WINDOWS
echo Warning  : Run this batch file on DOS ONLY (not DOS-BOX of Windows)
goto End

:UInstErr
echo !!! ERROR -- New IMEs did not install yet !!!
goto Usage

:ChkUinst
if not exist %2\system\FULLABC.OLD goto UInstErr

:UInstall
echo !!! Un-Install New IMEs Provided by Microsoft Office Chinese Version ...
@if exist %2\IC2CJ.TBL del %2\IC2CJ.TBL > %2\null
@if exist %2\system\MAIN3.DLL del %2\system\MAIN3.DLL > %2\null
@if exist %2\system\FULLABC.EXE del %2\system\FULLABC.EXE > %2\null
@if exist %2\system\CHAJEI.IME del %2\system\CHAJEI.IME > %2\null
@if exist %2\system\PHON.IME del %2\system\PHON.IME > %2\null
@if exist %2\system\QUICK.IME del %2\system\QUICK.IME > %2\null
@if exist %2\system\WINIME.IME del %2\system\WINIME.IME > %2\null

@if exist %2\system\FULLABC.OLD copy %2\system\FULLABC.OLD %2\system\FULLABC.EXE > %2\null
@if exist %2\system\CHAJEI.OLD copy %2\system\CHAJEI.OLD %2\system\CHAJEI.IME > %2\null
@if exist %2\system\PHON.OLD copy %2\system\PHON.OLD %2\system\PHON.IME > %2\null
@if exist %2\system\QUICK.OLD copy %2\system\QUICK.OLD %2\system\QUICK.IME > %2\null
@if exist %2\system\WINIME.OLD copy %2\system\WINIME.OLD %2\system\WINIME.IME > %2\null

@if exist %2\system\FULLABC.OLD del %2\system\FULLABC.OLD > %2\null
@if exist %2\system\CHAJEI.OLD del %2\system\CHAJEI.OLD > %2\null
@if exist %2\system\PHON.OLD del %2\system\PHON.OLD > %2\null
@if exist %2\system\QUICK.OLD del %2\system\QUICK.OLD > %2\null
@if exist %2\system\WINIME.OLD del %2\system\WINIME.OLD > %2\null

echo !!! New IMEs Are Un-Installed Successfully !!!
echo !!! Old IMEs Are Restored Successfully !!!

:End

