@echo off
if exist WGSERV.NT goto fin
wgsrmb
btrieve /m:34 /p:4096 /e >nul
cls
if not exist wgsdfcvt\*.cvt goto cvtskip
wgsdfcvt
if errorlevel 70 goto cvtbomb
if errorlevel 1 goto cvtabt
wgsrmb
goto cvtok
:cvtbomb
cls
echo 
echo There was a problem converting one of your old data files to its
echo new format.  Unable to continue with this installation.
echo Write down the error message in the box, and
pause
goto fin
:cvtabt
cls
echo 
echo This installation cannot continue unless you allow the conversion
echo of your old data files to their new formats.  When you are ready
echo to convert your data files, re-run this installation.
pause
goto fin
:cvtok
:cvtskip
if exist CNFTEMP.EXE ren WGSCNF.EXE WGSMTREE.EXE
if exist CNFTEMP.EXE ren CNFTEMP.EXE WGSCNF.EXE
wgsrmb
btrieve /m:34 /p:4096 /e >nul
if not exist WGSISUP.FLG goto skipfix
echo The server shut down abnormally... >WGSABSD.FLG
del WGSISUP.FLG
:skipfix
if "%1" == "GO" goto op50
if "%1" == "go" goto op50
if "%1" == "Go" goto op50
if "%1" == "gO" goto op50
WGSINTRO %1
goto mintret
:mintrcv
if not exist WGSISUP.FLG goto mint0
echo The server shut down abnormally... >WGSABSD.FLG
del WGSISUP.FLG
:mint0
WGSINTRO 0
goto mintret
:mint5
WGSINTRO 5
goto mintret
:mint7
WGSINTRO 7
:mintret
if errorlevel 200 goto opsys
if errorlevel 70 goto op70
if errorlevel 60 goto op60
if errorlevel 50 goto op50
if errorlevel 40 goto op40
if errorlevel 30 goto op30
if errorlevel 20 goto op20
if errorlevel 10 goto op10
:opsys
echo 
echo Type "WG"(Enter) to return to Worldgroup...
goto fin
:op10
wgsrmb
echo 
if exist cnfup.bat call cnfup.bat 1
wgscnf -L1
if errorlevel 1 goto waitmi
wgsmsx
if exist cnfdn.bat call cnfdn.bat 1
:cnfret
btrieve /m:34 /p:4096 /e >nul
goto mint5
:op20
echo 
call wgsmtree.bat
if errorlevel 1 goto waitmi
goto mint5
:op30
wgsrmb
echo 
if exist cnfup.bat call cnfup.bat 3
wgscnf -L3
if errorlevel 1 goto waitmi
wgsmsx
if exist cnfdn.bat call cnfdn.bat 3
goto cnfret
:op40
wgsrmb
echo 
if exist cnfup.bat call cnfup.bat 4
wgscnf -L4
if errorlevel 1 goto waitmi
wgsmsx
if exist cnfdn.bat call cnfdn.bat 4
goto cnfret
:op50
if not exist WGSCATA.FLG goto op50int
wgsridx catastro
if errorlevel 11 goto dfwait
if not errorlevel 10 goto skpgk2
copy gcvirdat\galfilk2.vir galfilk2.dat >nul
galfilkw
:skpgk2
del WGSCATA.FLG
:op50int
wgsint
wgsrmb
if exist wgscmaps.flg wgscmaps /m GALSSF
if exist wgscmaps.flg del wgscmaps.flg
call wgsbtr
wgsmsx
echo The server is up... >WGSISUP.FLG
echo WGSRIDX may be required (for CATASTRO fixup)... >WGSCATA.FLG
echo 
if not exist wgsup.bat goto nowgsup
call wgsup.bat
if errorlevel 251 goto nowgsup
if errorlevel 250 goto delflag
:nowgsup
wgserver
if errorlevel 80 goto finwgs
if errorlevel 50 goto dfwwgs
if errorlevel 49 goto delflag
if errorlevel 14 goto msh4
if errorlevel 13 goto msh3
if errorlevel 12 goto msh2
if errorlevel 11 goto msh1
if errorlevel 1 goto delflag
if exist WGSABSD.FLG del WGSABSD.FLG
if exist wgsdn.bat call wgsdn.bat
wgsfndo Cleanup
if exist WGSCLEAN.BAT call WGSCLEAN.BAT
goto op50int
:delflag
if exist wgsdn.bat call wgsdn.bat
if exist WGSISUP.FLG del WGSISUP.FLG
if exist WGSCATA.FLG del WGSCATA.FLG
goto mint0
:msh1
if exist wgsdn.bat call wgsdn.bat
wgsfndo Event-1
if exist WGSEVT1.BAT call WGSEVT1.BAT
goto op50int
:msh2
if exist wgsdn.bat call wgsdn.bat
wgsfndo Event-2
if exist WGSEVT2.BAT call WGSEVT2.BAT
goto op50int
:msh3
if exist wgsdn.bat call wgsdn.bat
wgsfndo Event-3
if exist WGSEVT3.BAT call WGSEVT3.BAT
goto op50int
:msh4
if exist wgsdn.bat call wgsdn.bat
wgsfndo Event-4
if exist WGSEVT4.BAT call WGSEVT4.BAT
goto op50int
:op60
wgsrmb
echo 
if exist cnfup.bat call cnfup.bat 6
wgscnf -L6
if errorlevel 1 goto waitmi
wgsmsx
if exist cnfdn.bat call cnfdn.bat 6
goto cnfret
:op70
wgsumenu
if errorlevel 100 goto waitmi
if errorlevel 5 goto op70xit5
if errorlevel 4 goto op70xit4
if errorlevel 3 goto op70xit3
if errorlevel 2 goto op70xit2
if errorlevel 1 goto op70xit1
goto mint7
:op70xit1
wgsrmb
call wgsutl
if errorlevel 1 goto waitmi
btrieve /m:34 /p:4096 /e > nul
wgsint
goto mint7
:op70xit2
wgsrmb
call wgsbtr
call wgsutl
if errorlevel 1 goto waitmi
btrieve /m:34 /p:4096 /e > nul
wgsint
goto mint7
:op70xit3
call wgsutl
if errorlevel 1 goto waitmi
wgsint
goto mint7
:op70xit4
if exist wgsaudit.old del wgsaudit.old
if exist wgsaudit.adt rename wgsaudit.adt wgsaudit.old
goto mint7
:op70xit5
wgsridx *
if not exist galfilk.dat goto skpgkw
copy gcvirdat\galfilk2.vir galfilk2.dat >nul
galfilkw
:skpgkw
copy wgsmajor.mcv junk.jnk >nul
del *.mcv
rename junk.jnk wgsmajor.mcv
wgsmsx wgsmajor
wgsmsx
del wgsint.ref
del wgsmdf.ref
wgsrbt
copy gcvirdat\wgsxrf2.vir wgsxrf2.dat >nul
wgsrbx
wgsrbk
wgsint
goto mint7
:dfwwgs
if exist wgsdn.bat call wgsdn.bat
:dfwait
del WGSISUP.FLG
:waitmi
wgsrmb
echo 
echo Write down the error message in the box, then press Ctrl-C to stop, or
pause
btrieve /m:34 /p:4096 /e >nul
goto mintrcv
:finwgs
if exist wgsdn.bat call wgsdn.bat
:fin
if not exist WGSERV.NT wgsrmb
