home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / bar2_14.zip / BaRstall.cmd < prev    next >
OS/2 REXX Batch file  |  1994-04-01  |  6KB  |  195 lines

  1. /* Installation script for BaR version 2.1 */
  2.  
  3. /* Load necessary Rexx funcs. */
  4. if RxFuncQuery( 'SysCurPos' ) then do
  5.    call RxFuncAdd 'SysCurPos', 'RexxUtil', 'SysCurPos'
  6. end
  7. if RxFuncQuery( 'SysMkDir' ) then do
  8.    call RxFuncAdd 'SysMkDir', 'RexxUtil', 'SysMkDir'
  9. end
  10. if RxFuncQuery( 'SysGetKey' ) then do
  11.    call RxFuncAdd 'SysGetKey', 'RexxUtil', 'SysGetKey'
  12. end
  13. if RxFuncQuery( 'SysDriveMap' ) then do
  14.    call RxFuncAdd 'SysDriveMap', 'RexxUtil', 'SysDriveMap'
  15. end
  16. if RxFuncQuery( 'SysCreateObject' ) then do
  17.    call RxFuncAdd 'SysCreateObject', 'RexxUtil', 'SysCreateObject'
  18. end
  19. if RxFuncQuery( 'SysIni' ) then do
  20.    call RxFuncAdd 'SysIni', 'RexxUtil', 'SysIni'
  21. end
  22.  
  23. /* Begin here */
  24. '@echo off'
  25.    'cls'
  26.    say "BaR Front End Installation"
  27.    say "~~~~~~~~~~~~~~~~~~~~~~~~~~"
  28.    say ""
  29.    say '  Enter the directory where BaR is to be installed (e.g. d:\bin).'
  30.    say '  Note:  BaR will create its own directory beneath the directory'
  31.    say '         you specify.'
  32.    say ''
  33.    say '    Directory: '
  34.    parse value SysCurPos() with col row
  35.    call SysCurPos col-1, 17
  36.    parse pull arg1
  37.    arg1 = arg1||'\BaR'
  38.  
  39. /*Create directory*/
  40.    say ''
  41.    say "  Creating subdirectory "arg1
  42.    rc = SysMkDir( arg1 )
  43.    if rc <> 0 then do
  44.       say ""
  45.       say "  BARSTALL could not create the subdirectory "arg1"."
  46.       say "  Should the BaR files be copied anyway (Y/n)?"
  47.       parse value SysCurPos() with col row
  48.       call SysCurPos col-1, 47
  49.       answer = SysGetKey()
  50.       parse upper var answer answer
  51.       if answer = "N" then do
  52.          say ""
  53.          say "  Installation aborted."
  54.          exit
  55.       end
  56.    end
  57.  
  58. /*Copy files to new directory*/
  59.    say ""
  60.    say "  Copying files:  "
  61.    parse value SysCurPos() with row col
  62.    call SysCurPos row-1, 18
  63.    say "BaR.exe"
  64.          "copy bar.exe "arg1" > nul"
  65.    call SysCurPos row, 18
  66.    say "BaR.ico"
  67.          "copy bar.ico "arg1" > nul"
  68.    call SysCurPos row+1, 18
  69.    say "BaRHlp.txt"
  70.          "copy barhlp.txt" arg1" > nul"
  71.  
  72. /* Create subdirs. for INI backup */
  73.    map = SysDriveMap( 'C:', 'USED' )
  74.    words  = Words( map )
  75.    DriveInfo.0 = words
  76.    count = 1
  77.    DriveInfo.0 = 0
  78.    do words
  79.       newstring.count  = SubWord( map, count, "1" )
  80.       count = count + 1
  81.    end
  82.    lastcol = 32 + count
  83.    count = 1
  84.    do words
  85.       left = Left( newstring.count, "1" )
  86.       newdir = arg1||"\Drive_"||left
  87.       rc = SysMkDir( newdir )
  88.       say ''
  89.       if rc <> 0 then do
  90.          say "  BARSTALL could not create the subdirectory "newdir"."
  91.       end
  92.       count = count + 1
  93.    end
  94.  
  95. /* Get date format for system */
  96.    say ""
  97.    call lineout 'return.tmp', ''
  98.    'date >date.tmp <return.tmp'
  99.    call lineout 'return.tmp'
  100.    line = linein( 'date.tmp', 1, 1 )
  101.    line = linein( 'date.tmp' )
  102.    call lineout 'date.tmp'
  103.    parse var line junk '(' format ')'
  104.    say '  BaRstall reports the following date format for your system: 'format
  105.    say '  Is this correct (Y/n)? '
  106.    parse value SysCurPos() with col row
  107.    call SysCurPos col-1, 25
  108.    answer = SysGetKey()
  109.    parse upper var answer answer
  110.    if answer = 'N' then do
  111.       say ''
  112.       say '  Enter the date format for your system (e.g. mm-dd-yy): '
  113.       parse value SysCurPos() with col row
  114.       call SysCurPos col-1, 59
  115.       parse pull format .
  116.       do forever
  117.          length = length( format )
  118.          if format <> '' then do
  119.             if length = 8 then
  120.                leave
  121.          end
  122.          say '                              ** ERROR!  Try again. **'
  123.          call SysCurPos col-1, 59
  124.          parse pull format .
  125.       end
  126.    end
  127.    call CreateINI
  128.  
  129.  
  130. /* Create a WPS object? */
  131.    say ""
  132.    say "  Would you like BARSTALL to create a WPS object (Y/n)?"
  133.    Parse value SysCurPos() with row col
  134.    call SysCurPos row-1, 56
  135.    YesObj = SysGetKey()
  136.    parse upper var YesObj YesObj .
  137.    say ''
  138.    if YesObj = "N" then signal PreExit
  139.    If SysCreateObject("WPProgram", "BaR Front End","<WP_DESKTOP>",,
  140.       "EXENAME="arg1"\BaR.exe" ) then
  141.       say "  Workplace Shell object has been created."
  142.    else do
  143.       say ''
  144.       say "  WPS object could not be created!"
  145.       say "  Probable cause:  an object called 'BaR Front End'"
  146.       say "                   already exists."
  147.       say "  Should BARSTALL create one anyway (y/N)?"
  148.       parse value SysCurPos() with row col
  149.       call SysCurPos row-1, 44
  150.       YesObj = SysGetKey()
  151.       parse upper var YesObj YesOjb .
  152.       if YesObj = "Y" then do
  153.             say ''
  154.             say "  Should the existing object be Updated or Recreated (u/R)?"
  155.             parse value SysCurPos() with row col
  156.             answer = SysGetKey()
  157.             parse upper var answer answer
  158.             call SysCurPos row-1, 61
  159.             parse upper pull answer .
  160.             if answer = "U" then
  161.                call SysCreateObject "WPProgram", "BaR Front End", "<WP_DESKTOP>",,
  162.                   "EXENAME="arg1"\BaR.exe", "U"
  163.             else
  164.                call SysCreateObject "WPProgram", "BaR Front End", "<WP_DESKTOP>",,
  165.                   "EXENAME="arg1"\BaR.exe", "R"
  166.       end
  167.       Signal PreExit
  168.    end
  169.    signal DoExit
  170.  
  171. PreExit:
  172.    say ""
  173.    say "  You chose not to create a WPS object.  If you would like to start"
  174.    say "  BaR from any directory, add the directory "arg1" to your path"
  175.    say "  statement in config.sys, then add the environment variable"
  176.    say "  SET BAR_INI="||arg1||" to your config.sys, and, lastly, reboot."
  177.    signal DoExit
  178.  
  179. CreateINI:
  180.    say ''
  181.    say '  Creating file:  '||arg1||'\BaR.ini'
  182.    call SysIni arg1||'\BaR.ini', 'BaR', 'DateFormat', format
  183.    call SysIni arg1||'\BaR.ini', 'BaR', 'BaR_Dir', arg1||'\BaR.ini'
  184.    call SysIni arg1||'\BaR.ini', 'BaR', 'INIOptions', 'No 5'
  185.    call SysIni arg1||'\BaR.ini', 'BaR', 'Invocation', '0'
  186.    'del return.tmp >nul'
  187.    'del date.tmp >nul'
  188.    return
  189.  
  190. DoExit:
  191.    say ""
  192.    say "  Installation complete."
  193.    say ""
  194.    exit
  195.