home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / mswos2.zip / fix-wos2.cmd next >
OS/2 REXX Batch file  |  1994-05-17  |  6KB  |  161 lines

  1. /* Compares current directory to zip file.          */
  2. /* Deletes files that no longer exist after confirmation. */
  3.  
  4. parse arg windos winos2
  5. if winos2='' | windos='' then do
  6.   '@prompt'
  7.   say "This utility will fix winos2 so that it may be used from MSDOS."
  8.   say "Then you don't have to keep a copy of Windows 3.1 on your hard drive."
  9.   say "It does this by changing three files in your \OS2\MDOS\WINOS2\SYSTEM"
  10.   say "directory each time you boot."
  11.   say ""
  12.   say "In order to use this program you must first install Microsoft"
  13.   say "Windows 3.1 (3.11 might work.)  This must be installed from DOS."
  14.   say "Go ahead and install any video drivers if you like."
  15.   say ""
  16.   say "Then from OS/2 you need to install WINOS2 to a FAT partition."
  17.   say "If your OS2 drive is HPFS, you will need to hit the MORE button"
  18.   say "next to WINOS2 support and change the drive letter when you"
  19.   say "install.  When you setup the WINOS2 desktop, be sure to tell"
  20.   say "OS2 to copy the existing Microsoft Windows 3.1 desktop."
  21.   say ""
  22.   say "Finally, run this program specifying the complete path of MS Windows"
  23.   say "and WINOS2 in that order.  This will copy a bunch of files from"
  24.   say "your MS Windows to WINOS2 and change your MSDOS autoexec.bat and"
  25.   say "OS/2 config.sys.  Then, everytime you reboot, wdisplay.exe will be"
  26.   say "run to copy 3 files to your \OS2\MDOS\WINOS2\SYSTEM directory and"
  27.   say "set the display.drv line in your system.ini."
  28.   say "WARNING: This may not work right on a dual-boot system."
  29.   say ''
  30.   say "This program is donated to the public domain by Scott Maxwell."
  31.   '@pause'
  32.   say ''
  33.   say "Usage: fix-os2 <ms_windows_path> <winos2_path>"
  34.   exit(1)
  35. end
  36.  
  37. if substr(winos2,2,2) \= ':\' then do
  38.    say "Path name must include drive letter and '\' -" winos2
  39.    exit(1)
  40. end
  41. if Right(winos2,1) = '\' then
  42.     winos2 = Left(winos2,length(winos2)-1)
  43. if Stream(winos2'\system\os2k386.exe', 'C', 'QUERY EXISTS') = '' then do
  44.     say winos2 "does not appear to contain WINOS2"
  45.     exit(1)
  46. end
  47.  
  48. if substr(windos,2,2) \= ':\' then do
  49.    say "Path name must include drive letter and '\' -" windos
  50.    exit(1)
  51. end
  52. if Right(windos,1) = '\' then
  53.     windos = Left(windos,length(windos)-1)
  54. if Stream(windos'\system\krnl386.exe', 'C', 'QUERY EXISTS') = '' then do
  55.     say windos "does not appear to contain MS Windows"
  56.     exit(1)
  57. end
  58.  
  59.   doslen = Length(windos)
  60.   os2len = Length(winos2)
  61.   CALL RxFuncAdd 'SysLoadFuncs','RexxUtil','SysLoadFuncs'
  62.   Call SysLoadFuncs
  63.   Call SysFileTree windos'\*','dosdirs','DSO'
  64.   do i=1 to dosdirs.0
  65.     Call SysMkDir topath(dosdirs.i)
  66.   end
  67.  
  68.   say "Copying MS Windows files to" winos2
  69.   Call SysFileTree windos'\*','dosfiles','FSO'
  70.   Call SysFileTree winos2'\*','os2files','FSO'
  71.   do i = 1 to os2files.0
  72.     hold = translate(SubStr(os2files.i,os2len+1))
  73.     os2files.hold = 1
  74.     drop os2files.i
  75.   end
  76.   do i = 1 to dosfiles.0
  77.     hold = translate(SubStr(dosfiles.i,doslen+1))
  78.     if os2files.hold \= 1 then do
  79.       "@copy" dosfiles.i topath(dosfiles.i) "> nul"
  80.       say "Copying" dosfiles.i
  81.     end
  82.   end
  83.   say "Making OS/2 and MS-DOS directories"
  84.   Call SysMkDir winos2'\SYSTEM\DOS'
  85.   Call SysMkDir winos2'\SYSTEM\OS2'
  86.   "@copy" winos2"\SYSTEM\user.exe" winos2"\SYSTEM\OS2 > nul"
  87.   "@copy" winos2"\SYSTEM\gdi.exe" winos2"\SYSTEM\OS2 > nul"
  88.   "@copy" winos2"\SYSTEM\mouse.drv" winos2"\SYSTEM\OS2 > nul"
  89.   "@copy" windos"\SYSTEM\user.exe" winos2"\SYSTEM\DOS > nul"
  90.   "@copy" windos"\SYSTEM\gdi.exe" winos2"\SYSTEM\DOS > nul"
  91.   "@copy" windos"\SYSTEM\mouse.drv" winos2"\SYSTEM\DOS > nul"
  92.   say "Fixing AutoExec.Bat and Config.Sys"
  93.   call 'Search' "C:\AutoExec.Bat" windos winos2
  94.   call 'Search' "C:\Config.Sys" windos winos2
  95.   call SysFileSearch "wdisplay","C:\AutoExec.Bat",'line.','N'
  96.   if line.0 = 0 then do
  97.      say "Adding WDisplay.Exe to C:\AutoExec.Bat"
  98.      hold = charin("C:\AutoExec.Bat",,Chars("C:\AutoExec.Bat"))
  99.      call charout "C:\AutoExec.Bat"
  100.      call SysFileDelete 'c:\autoexec.bat'
  101.      call charout "C:\AutoExec.Bat",winos2"\wdisplay "winos2"\system.ini"'0d0a'x||hold
  102.      call charout "C:\AutoExec.Bat"
  103.   end
  104.   root=FileSpec('Drive',Value('SYSTEM_INI',,'OS2ENVIRONMENT'))
  105.   Say "Fixing" root"\Config.Sys"
  106.   call SysFileSearch "wdisplay",root"\Config.Sys",'line.'
  107.   if line.0 = 0 then do
  108.      say "Adding WDisplay.Exe to" root"\Config.Sys"
  109.      call charout root"\Config.Sys","CALL="winos2"\wdisplay.exe"'0d0a'x
  110.      call charout root"\Config.Sys"
  111.   end
  112.  
  113.   say "Fixing ProgMan.Ini"
  114.   call 'Search' winos2"\ProgMan.Ini" windos winos2
  115.  
  116.   say "Fixing System.Ini"
  117.   call SysFileSearch "display.dos",winos2"\System.Ini",'line.'
  118.   if line.0 = 0 then do
  119.      call SysFileSearch "display.drv",windos"\System.Ini",'line.'
  120.      do lnum = 1 to line.0
  121.     if Translate(Left(line.lnum,11)) = "DISPLAY.DRV" then leave
  122.      end
  123.      file = winos2"\System.Ini"
  124.      lp = LastPos('.',file)
  125.      bakfile = Left(file,LastPos('.',file))'bak'
  126.  
  127.      if Stream(bakfile,'C','QUERY EXISTS') \= '' then
  128.     call SysFileDelete bakfile
  129.   
  130.      '@ren' file bakfile '> nul'
  131.      l = ''
  132.      do while l \= "[boot]"
  133.     l = linein(bakfile)
  134.     call lineout file, l
  135.      end
  136.      call lineout file,Left(line.lnum,8)'dos'SubStr(line.lnum,12)
  137.      do while lines(bakfile)
  138.     l = linein(bakfile)
  139.     call lineout file,l
  140.      end
  141.      call lineout bakfile
  142.      call lineout file
  143.   end
  144.   '@copy wdisplay.exe' winos2' > nul'
  145.   
  146. exit(0)
  147.  
  148. topath:
  149.   arg name
  150.   return winos2||SubStr(name,doslen+1)
  151.  
  152. Directory: procedure
  153.   arg Name
  154.   if Length(Name) > 3 then
  155.     if Right(Name,1) = '\' then
  156.       Name = Left(Name,LENGTH(Name)-1)
  157.   n = 'DIRECTORY'(Name)
  158.   if Right(n,1) \= '\' then
  159.     n = n'\'
  160.   return n
  161.