home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR24 / WUZ10A.ZIP / INST-WUZ.CMD next >
OS/2 REXX Batch file  |  1993-12-14  |  5KB  |  186 lines

  1. /* Rexx program to install WUZ */
  2. /* (c) Copyright 1993 Scott Maxwell. */
  3.  
  4. Call RxFuncAdd 'SysLoadFuncs','RexxUtil','SysLoadFuncs'
  5. Call SysLoadFuncs
  6.  
  7. arg where tempdir
  8.  
  9.   Say "Welcome to Workplace UnZip!"'0a'x
  10.  
  11.   Say "WUZ is a series of REXX functions to give you access to archive"
  12.   Say "files (including .ARC, .ARJ, .LZH, .TAR, .Z, .ZIP and .ZOO) from"
  13.   Say "the Workplace Shell or the command line."'0a'x
  14.  
  15. top:
  16. if where = '' | tempdir = '' then do
  17.   where = ''
  18.   path = Value('PATH',,'OS2ENVIRONMENT')
  19.  
  20.   Say "WUZ must be installed in a directory on your PATH:"'0a'x
  21.   i = 1
  22.   found = 0
  23.   dir. = ''
  24.   do forever
  25.     parse var path dir.i ';' path
  26.     if Right(dir.i,1) \= '\' then
  27.       dir.i = dir.i'\'
  28.     if SubStr(dir.i,2,1) = ':' then do
  29.       if Length(CharIn(dir.i'wuz.cmd',1,1)) = 1 then do
  30.         found=i
  31.     Call CharOut dir.i'wuz.cmd'
  32.       end
  33.       i=i+1
  34.     end
  35.     if path='' then leave
  36.   end
  37.  
  38.   if found > 0 then do
  39.     Say '0a'x"WUZ seems to be installed in" dir.found
  40.     Call CharOut ,"Do you wish to uninstall WUZ? "
  41.     parse upper pull ans
  42.     if Left(ans,1)='Y' then do
  43.       say "Erasing:    wuz.cmd"
  44.       say "        wuz.ico"
  45.       say "        post-wuz.cmd"
  46.       say "        zipstrip.cmd"
  47.       say "        open-dir.cmd"
  48.       say "        kill-dir.cmd from" dir.found
  49.       Call SysFileDelete dir.found'wuz.cmd'
  50.       Call SysFileDelete dir.found'wuz.ico'
  51.       Call SysFileDelete dir.found'post-wuz.cmd'
  52.       Call SysFileDelete dir.found'zipstrip.cmd'
  53.       Call SysFileDelete dir.found'open-dir.cmd'
  54.       Call SysFileDelete dir.found'kill-dir.cmd'
  55.       Call SysDestroyObject '<WorkplaceUnZip>'
  56.       exit(1)
  57.     end      
  58.     Call CharOut ,"Do you wish to install over the old copy? "
  59.     parse upper pull ans
  60.     if Left(ans,1)='Y' then
  61.       where = dir.found
  62.   end
  63.   if where = '' then do
  64.     i = i-1
  65.     dir.0 = i
  66.     tr = Trunc((i+1)/2)
  67.     do i=1 to tr
  68.       i2 = i+tr
  69.       build  = '('i')' dir.i
  70.       if dir.i2 \= '' then
  71.         build2 = '('i2')' dir.i2
  72.       else
  73.         build2 = ''
  74.       say insert(build,build2,,40)
  75.     end
  76.     Call CharOut ,'0a'x"Enter the number of your selection: "
  77.     parse pull ans
  78.     if ans > 0 & ans <= dir.0 then
  79.       where = dir.ans
  80.     else do
  81.       say "Invalid number.  Aborting"
  82.       exit(0)
  83.     end
  84.   end
  85.   tempdir = '\'
  86.   hold = directory()
  87. end
  88. else do
  89.   hold = directory()
  90.   where2 = directory(where)
  91.   if where2 = '\' then do
  92.     say "Unknown directory:" where
  93.     where = ''
  94.     Call Directory hold
  95.     Signal top
  96.   end
  97.   where = where2
  98.   tempdir = directory(tempdir)
  99. end
  100.  
  101. do while tempdir = '\'
  102.   Call CharOut ,"Where should I create temporary directories? "
  103.   parse pull tempdir
  104.   if tempdir='' then do
  105.     Say "Aborting install"
  106.     exit(0)
  107.   end
  108.   call Directory hold
  109.   temp = tempdir
  110.   tempdir = directory(tempdir)
  111.   if tempdir = '\' then do
  112.     Call CharOut ,temp "does not exist.  Should I create it? "
  113.     parse upper pull ans
  114.     if Left(ans,1) = 'Y' then do
  115.       if SysMkDir(temp) then
  116.         say "Can't create" temp
  117.       else
  118.         tempdir = temp
  119.     end
  120.   end
  121. end
  122.  
  123. call Directory hold
  124.  
  125. if where \= '.' then do
  126.   from = directory()
  127.   to = directory(where)
  128.   if to = '\' then do
  129.     say where': directory not found'
  130.     exit(1)
  131.   end
  132.   say '0a'x"Copying:    wuz.cmd"
  133.   say "        wuz.ico"
  134.   say "        post-wuz.cmd"
  135.   say "        zipstrip.cmd"
  136.   say "        open-dir.cmd"
  137.   say "        kill-dir.cmd to "to
  138.  
  139.   Drive = Left(tempdir,2)
  140.   Call SysFileDelete 'wuz.cmd'
  141.   Call LineOut 'wuz.cmd',linein(from'wuz.cmd')
  142.   Call LineOut 'wuz.cmd',linein(from'wuz.cmd')
  143.   Call LineOut 'wuz.cmd',linein(from'wuz.cmd')
  144.   Call LineIn from'wuz.cmd'
  145.   Call LineIn from'wuz.cmd'
  146.   Call LineOut 'wuz.cmd',"Drive    = '"Drive"'"
  147.   Call LineOut 'wuz.cmd',"DestPath = '"tempdir"'"
  148.   do while lines(from'wuz.cmd') > 0
  149.     Call LineOut 'wuz.cmd',LineIn(from'wuz.cmd')
  150.   end
  151.   '@copy' from'wuz.ico > nul'
  152.   '@copy' from'post-wuz.cmd > nul'
  153.   '@copy' from'zipstrip.cmd > nul'
  154.   '@copy' from'open-dir.cmd > nul'
  155.   '@copy' from'kill-dir.cmd > nul'
  156.   Call Directory from
  157. end
  158. else
  159.   to = directory()
  160.  
  161. Call SysDestroyObject '<WorkplaceUnZip>'
  162. Call SysCreateObject "WPProgram", "WPS Unzip", "<WP_DESKTOP>",,
  163.     "OBJECTID=<WorkplaceUnZip>;PROGTYPE=PM;EXENAME="to"wuz.cmd;ASSOCFILTER=*.arc,*.arj,*.lzh,*.tar,*.z,*.zip,*.zoo"
  164.  
  165. Say '0a'x"Workplace UnZip has been successfully installed."
  166. Say "Try it out and see if you like it.  If you do, I would appreciate"
  167. Say "a small cash donation ($10 maybe) or at least a note telling me"
  168. Say "what you think.  My Usenet address is scott.maxwell@channel1.com."
  169. Say "Any money should go to:  Pat Maxwell"
  170. Say "                         1587 E. Modesto Ave."
  171. Say "                         Camarillo, CA 93010 U.S.A."'0a'x
  172.  
  173. Say "You may also rerun Inst-WUZ.Cmd to uninstall."
  174. Say "For more information about Workplace UnZip, read README.WUZ."
  175. exit(0)
  176.  
  177. Directory: procedure
  178.   arg Name
  179.   if Length(Name) > 3 then
  180.     if Right(Name,1) = '\' then
  181.       Name = Left(Name,LENGTH(Name)-1)
  182.   n = 'DIRECTORY'(Name)
  183.   if Right(n,1) \= '\' then
  184.     n = n'\'
  185.   return n
  186.