home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 33 VDrivers / 33-VDrivers.zip / 1601_200.zip / INSTALL.CMD < prev    next >
OS/2 REXX Batch file  |  1996-07-25  |  10KB  |  316 lines

  1. /********************************************************************/
  2. /*         MGA OS/2 PM drivers installation batch file              */
  3. /********************************************************************/
  4.  
  5. '@ECHO OFF'
  6. say 'MATROX MGA Millennium/Mystique Driver'
  7.  
  8. call rxfuncadd sysloadfuncs, rexxutil, sysloadfuncs
  9. call sysloadfuncs
  10.  
  11.  
  12. CurDir = Directory()
  13. parse SOURCE cmdd
  14. cmdd = word(cmdd,3)
  15. SrcDrv = left(cmdd, length(cmdd)-length('install.cmd')-1)
  16. Dstdrv = 'C:'           /* default value */
  17. AutoInstall = 0         /* default value */
  18.  
  19. /********************************************************************/
  20. /* Get arguments if any                                             */
  21. /********************************************************************/
  22.  
  23. Parse Arg all
  24.  
  25. ArgCount=words(all)
  26. if ArgCount > 4 then ArgCount = 4
  27. srcset=0
  28. dstset=0
  29. OS2Refresh=0
  30. If ArgCount > 0 then do i=1 to ArgCount
  31.     ntmp = translate(word(all,i))
  32.     select /* ntmp */
  33.         when ntmp ='/U' then AutoInstall = 1
  34.  
  35.         when ntmp ='/OS2REFRESH' then OS2Refresh = 1
  36.         otherwise do
  37.             if srcset=0 then do
  38.                 Srcdrv=ntmp
  39.                 srcset=1
  40.             end
  41.             else do
  42.                 Dstdrv=ntmp
  43.                 dstset=1
  44.             end
  45.         end /* otherwise */
  46.     end /* select ntmp */
  47. end /* do i=1 to ArgCount */
  48.  
  49. if srcset=1 then signal FoundSrcDrv
  50.  
  51. if OS2Refresh=1 then do
  52.     say
  53.     say 'Note: If you have a DDC monitor, and you install with the /OS2REFRESH option,'
  54.     say '      then the refresh rate that you select from the System Icon will be used'
  55.     say '      instead of your monitor''s DDC refresh rates.'
  56.     say
  57.     rc = charout(,'Do you wish to install with the /OS2REFRESH option (Y/N)? Y')
  58.     pull answer .
  59.     if answer = 'N' then OS2Refresh = 0
  60. end
  61.  
  62. SearchRep = 0
  63. SearchAgain:
  64. if stream(Srcdrv'MGAX64.DSC','C','query exists') \= "" then signal FoundSrcDrv
  65. Srcdrv=Srcdrv'\OS2\'
  66. if stream(Srcdrv'MGAX64.DSC','C','query exists') \= "" then signal FoundSrcDrv
  67.  
  68. SearchRep = SearchRep + 1
  69.  
  70. select
  71.    when SearchRep=1 then do
  72.         Srcdrv = CurDir
  73.         signal SearchAgain
  74.         end
  75.    when SearchRep=2 then do
  76.         DrvLetter = 'A'
  77.         Srcdrv = DrvLetter':'
  78.         signal SearchAgain
  79.         end
  80.     otherwise nop
  81. end
  82.  
  83. if DrvLetter \= 'Z' then do
  84.     DrvLetter= D2C(C2D(DrvLetter)+1)
  85.     Srcdrv = DrvLetter':'
  86.     signal SearchAgain
  87. end
  88.  
  89. Srcdrv='A:'
  90. signal NotFoundSrcDrv
  91.  
  92. FoundSrcDrv:
  93. say 'Install from 'Srcdrv
  94.  
  95. /* if dstset=1 then signal FoundDstDrv */
  96.  
  97. /********************************************************************/
  98. /* Search for OS2 system path in PATH environment                   */
  99. /********************************************************************/
  100.  
  101. Path = value('PATH',,'OS2ENVIRONMENT')
  102. if Path = '' then signal ENDSEARCH
  103.  
  104. ntmp = pos(':\OS2;', Path)
  105. if ntmp = 0 then signal ENDSEARCH
  106.  
  107. BootedDrv = substr(Path, ntmp - 1, 2)
  108. if dstset = 0 then Dstdrv = BootedDrv
  109. if BootedDrv = Dstdrv then DstRunning = 1
  110.  
  111. FoundDstDrv:
  112. say 'Install to   'Dstdrv
  113.  
  114. /*****************************************************************************/
  115. /*                 Checking the default values                               */
  116. /*****************************************************************************/
  117.  
  118.                                                /* checking source      */
  119. if stream(Srcdrv'MGAX64.DSC', 'C', 'query exists') \= "" then signal CheckDst
  120. Srcdrv=Srcdrv'\OS2\'
  121. if stream(Srcdrv'MGAX64.DSC', 'C', 'query exists') = "" then signal RESUME
  122.  
  123. CheckDst:
  124.  
  125. FileName=Dstdrv'\OS2KRNL'                       /* checking target      */
  126. 'attrib -r -s -h 'FileName
  127. if stream(FileName, 'C', 'query exists') = "" then signal RESUME
  128. 'attrib +h +s +r 'FileName
  129.  
  130. signal StartInstall
  131.  
  132. /********************/
  133. /* Ask the User     */
  134. /********************/
  135.  
  136. NotFoundSrcDrv:
  137. RESUME:
  138. cls
  139. say ''
  140. say ''
  141. say 'Source dir will be:' Srcdrv
  142. say 'Destination drive will be:' Dstdrv
  143. say 'Is the above information correct? (Y/N): Y'
  144. pull answer
  145. if answer = 'N' then signal askdrives
  146.  
  147. if stream(Srcdrv'MGAX64.DSC', 'C', 'query exists') \= "" then signal CheckDst1
  148. Srcdrv=Srcdrv'\OS2\'
  149. if stream(Srcdrv'MGAX64.DSC', 'C', 'query exists') = "" then signal usage0
  150.  
  151. CheckDst1:
  152. FileName=Dstdrv'\OS2KRNL'
  153. 'attrib -r -s -h 'FileName
  154. if stream(FileName, 'C', 'query exists') = "" then signal usage0
  155. 'attrib +h +s +r 'FileName
  156.  
  157. say 'Source Directory will be 'Srcdrv
  158. say 'Ready to install? (Y/N): Y'
  159. pull answer
  160. if answer \= 'N' then signal StartInstall
  161.  
  162. say 'INSTALLATION ABORT'
  163. signal end
  164.  
  165. StartInstall:
  166. say 'PLEASE WAIT ...'
  167.  
  168. NewDir=directory(Dstdrv'\')             /* go to root off OS/2 drive */
  169.  
  170. /********************************************/
  171. /* remove any MGA statement from CONFIG.SYS */
  172. /********************************************/
  173.  
  174. InnF=Dstdrv'\CONFIG.MGA'
  175. OutF=Dstdrv'\CONFIG.SYS'
  176. 'copy 'OutF' 'InnF' >nul'
  177. 'del 'OutF
  178.  
  179. do until lines(InnF) = 0
  180.     InStr = linein(InnF)
  181.     select
  182.         when pos('VVGA.SYS', InStr) > 0     then nop
  183.         when pos('VSVGA.SYS', InStr) > 0    then nop
  184.         when pos('MGAKRNL.SYS', InStr) > 0  then nop    /* Terminator       */
  185.         when pos('MGA=', InStr) > 0         then nop    /* Termin / Millen  */
  186.         when pos('MGARES=', InStr) > 0      then nop    /* Terminator < 2.0 */
  187.         when pos('VIO_MGA', InStr) > 0      then nop    /* Termin / Millen  */
  188.         when pos('RAMBIOS.SYS', InStr) > 0  then nop    /* Terminator < 2.0 */
  189.         when pos('VMGA.SYS', InStr) > 0     then nop    /* Terminator       */
  190.         when pos('KMGAX64.SYS', InStr) > 0  then nop    /* Millennium       */
  191.         when pos('VMGAX64.SYS', InStr) > 0  then nop    /* Millennium       */
  192.         otherwise
  193.         do
  194.             if pos('LIBPATH=', InStr) > 0   then        do
  195.                 itmp = pos(':\MGA\OS', InStr)
  196.                 if itmp > 0 then stmp=delstr(InStr, itmp-1, 11)
  197.                 else stmp=InStr
  198.                 call lineout OutF, stmp
  199.             end
  200.             else do
  201.                 itmp = pos(':\MGA\OS2', InStr)
  202.                 if itmp = 0 then  call lineout OutF, InStr
  203.                 end
  204.         end
  205.     end
  206. end
  207.  
  208. call stream OutF, 'c', 'close'
  209. call stream InnF, 'c', 'close'
  210.  
  211. /**********************************************/
  212. /* remove any MGA statement from autoexec.bat */
  213. /**********************************************/
  214.  
  215. 'call 'Srcdrv'FIXAUTO.CMD 'Dstdrv' ON'
  216.  
  217. /**********************************/
  218. /* Call OS/2 Installation process */
  219. /**********************************/
  220.  
  221. if OS2Refresh=1 then do
  222.     'copy 'Srcdrv'matrox.pmi 'Dstdrv'\OS2\svgadata.pmi > nul'
  223.     'copy 'Srcdrv'video.cfg  'Dstdrv'\OS2\video.cfg > nul'
  224. end
  225. else do
  226.     'if exist 'Dstdrv'\OS2\svgadata.pmi del 'Dstdrv'\OS2\svgadata.pmi > nul'
  227.     'if exist 'Dstdrv'\OS2\video.cfg del 'Dstdrv'\OS2\video.cfg > nul'
  228. end
  229.  
  230. NewDir=directory(Dstdrv'\OS2\INSTALL')
  231. 'if exist MGA8.DSC del MGA8.DSC > nul'
  232. 'copy   'Srcdrv'MGAX64.DSC .>nul'
  233.  
  234. /***************************************************/
  235. /* save OS2's Keyboard driver (ver > 2.11 is Warp) */
  236. /***************************************************/
  237. ver = SysOS2Ver()
  238.  
  239. if ver > '2.11' then do                             /* Warp */
  240.     option=' /S:'Srcdrv' /T:'Dstdrv'\'
  241.     if AutoInstall = 1 then option=' /PD:'Srcdrv'MGAX64.DSC'option
  242.     end
  243. else do                                             /* not Warp */
  244.     option=''
  245.     end
  246.  
  247. /**************************************************/
  248. /* Call dspinstl to install drivers               */
  249. /**************************************************/
  250.  
  251. 'DSPINSTL.EXE'option
  252. IstRetCode = rc
  253.  
  254. /**************************************************************/
  255. /* restore CONFIG.SYS and AUTOEXEC.BAT in case abort or error */
  256. /**************************************************************/
  257. if IstRetCode \= 0 then do
  258.     NewDir=directory(Dstdrv'\')
  259.     'copy config.mga config.sys >nul'
  260.     'copy autoexec.mga autoexec.bat >nul'
  261.     'del  *.mga'
  262.     say 'INSTALLATION ABORT'
  263.     end
  264.  
  265. else do
  266.  
  267.     /**********************************************************************/
  268.     /* Delete obsolete files.                                             */
  269.     /* An old level mga.inf is identified by the existence of mgamon.exe. */
  270.     /**********************************************************************/
  271.     'if exist 'Dstdrv'\MGA\OS2\mgamon.exe  del 'Dstdrv'\MGA\OS2\mga.inf  > nul'
  272.     'if exist 'Dstdrv'\MGA\OS2\MGAMON.EXE  del 'Dstdrv'\MGA\OS2\MGAMON.EXE  > nul'
  273.     'if exist 'Dstdrv'\MGA\OS2\syslevel.mil  del 'Dstdrv'\MGA\OS2\syslevel.mil  > nul'
  274.  
  275.     /**********************************************************/
  276.     /* If the installation target drive is the one that's     */
  277.     /* currently booted, create the MGA objects.              */
  278.     /**********************************************************/
  279.     if DstRunning = 1
  280.     then 'call' Dstdrv'\mga\os2\mgaobj'
  281.     else do
  282.         say 'To complete installation, boot from 'Dstdrv' and run MGAOBJ'
  283.         say 'and then MGAHK, both from the 'Dstdrv'\MGA\OS2 directory.'
  284.         end
  285.     end
  286.  
  287. signal end
  288.  
  289. ASKDRIVES:
  290. say 'Enter source drive ('Srcdrv')'
  291. pull answer
  292. if   answer = "" then nop
  293. else Srcdrv = answer'\OS2'
  294. say 'Enter destination drive ('Dstdrv')'
  295. pull answer
  296. if   answer = "" then nop
  297. else Dstdrv = answer
  298. signal RESUME
  299.  
  300. USAGE0:
  301. say 'File' FileName ' does not exist'
  302. USAGE:
  303. say ''
  304. say 'Usage:'
  305. say '   install src: dst:'
  306. say '   Where src is the drive from which you are installing the driver'
  307. say '   and dst is your OS/2 boot drive.'
  308. say 'Example:'
  309. say '   b:install b: d:'
  310. say '   a:install'
  311. say '   e:\os2\install'
  312.  
  313. end:
  314. call directory CurDir
  315. exit
  316.