/********************************************************************/
/********************************************************************/

'@echo off'
CurDir=directory()

/********************************************************************/
/* Seach for OS2 system path in PATH environement		    */
/********************************************************************/

env = 'OS2ENVIRONMENT'
Path = value('PATH',,env)
if Path = '' then signal ENDSEARCH

ntmp = pos(':\OS2;', Path)
if ntmp = 0 then signal ENDSEARCH

Dstdrv=substr(Path, ntmp-1,2)


/*********************************************************************/
/* remove any MGA statement from CONFIG.SYS			     */
/*********************************************************************/

NewDir=directory(Dstdrv'\')             /* go to root off OS/2 drive */
InnF=Dstdrv'\CONFIG.MGA'
OutF=Dstdrv'\CONFIG.SYS'
'copy 'OutF' 'InnF' >nul'
'del 'OutF

do until lines(InnF) = 0
    InStr = linein(InnF)
    select
	when pos('MGAKRNL.SYS', InStr) > 0  then nop
	when pos('MGA=', InStr) > 0	    then nop
	when pos('MGARES=', InStr) > 0	    then nop
	when pos('VIO_MGA', InStr) > 0	    then nop
	when pos('RAMBIOS.SYS', InStr) > 0  then nop
	when pos('VMGA.SYS', InStr) > 0     then nop
	otherwise
	do
	    if pos('LIBPATH=', InStr) > 0   then	do
		itmp = pos(':\MGA\OS', InStr)
		if itmp > 0 then stmp=delstr(InStr, itmp-1, 11)
		else stmp=InStr
		call lineout OutF, stmp
	    end
	    else do
		itmp = pos(':\MGA\OS2', InStr)
		if itmp = 0 then  call lineout OutF, InStr
                end
	end
    end
end

call stream OutF, 'c', 'close'
call stream InnF, 'c', 'close'
'del 'InnF

/**********************************/
/* remove MGAs from  AUTOEXEC.BAT */
/**********************************/

'call 'Dstdrv'\MGA\OS2\FIXAUTO.CMD 'Dstdrv' OFF'

NewDir=directory(Dstdrv'\OS2\INSTALL')	    /* go to root off OS/2 drive    */
'DSPINSTL.EXE'				    /* install other display driver */

call directory CurDir
exit

ENDSEARCH:
say 'Can not locate OS/2 System drive'
