home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / pm-app.zip / startapp.cmd < prev    next >
OS/2 REXX Batch file  |  1997-04-29  |  3KB  |  86 lines

  1. /* STARTAPP.CMD 
  2.  
  3.       REXX Program to start KAT and STOPAPP.CMD at a particular time.
  4.       This program can be modified to control any OS/2 PM application.
  5.       This program requires REXXUTIL.DLL
  6.       Press Q or q to stop this program.
  7.  
  8.       Released to Public Domain - feel free to use and modify this code to your content.
  9.  
  10.       Author: A. Schwarz 
  11.       Date: 4-28-97
  12. */
  13.  
  14. IF LoadRexxUtil() THEN
  15.   EXIT
  16.                        /* If you want to modify this program to start any other program, then */
  17.                        /* change the three lines below. */
  18.  
  19. StartTime = '08:00'    /* This is the start time of the application. Use military time and fill */
  20.                        /* in a zero for single digit hour, i.e 1:00am = 01:00 */
  21.  
  22. AppName = 'KAT.EXE'    /* This is the application to be started. Must be an OS/2 PM application */
  23. AppDir = 'kopykat'     /* Directory where the application resides. Note: STARTAPP.CMD and STOPAPP.CMD */
  24.                        /* must be run from same drive as the AppName program. */
  25.  
  26.  
  27. SAY 'Scheduler Program for ' || AppName
  28. SAY 'Start Time: ' || StartTime
  29. SAY ''
  30. SAY 'Press Q to quit program.'
  31. SAY ''
  32.  
  33. OldTime = LEFT(TIME(), 5)
  34. SAY "Current Time: " || OldTime
  35.  
  36. Loop:
  37.  
  38. CurrTime = LEFT(TIME(), 5)        /* get current time in hh:mm format */
  39. IF CurrTime <> OldTime THEN
  40.    DO
  41.      SAY "Current Time: " || CurrTime   /* display current time every minute */
  42.      OldTime = CurrTime
  43.    END
  44.  
  45. IF StartTime = CurrTime THEN      /* StartTime and CurrTime match, start the application and close this program */
  46.    DO
  47.       SAY "Kat started."
  48.       '@echo off'
  49.       'cd\' || AppDir
  50.       'start ' || AppName || ' /a'    /* starts KAT.EXE with the option /a which is auto-answer */
  51.       'cd\'
  52.       'start stopapp'                 /* start STOPAPP.CMD which will terminate the application */
  53.       'exit'                          /* terminate STARTAPP.CMD (this program) */
  54.    END
  55. ELSE                      /* StartTime does not match CurrTime */
  56.    count = 0
  57.    DO WHILE count < 10
  58.       CALL SysSleep 1           /* wait 10 seconds */
  59.       count = count + 1
  60.  
  61.       IF CHARS() <> 0 THEN   /* check if there is a keyboard entry and get key if any */
  62.         DO
  63.           key = SysGetKey('NOECHO')
  64.           IF key = 'q' | key = 'Q' THEN
  65.              EXIT
  66.         END
  67.    END
  68.  
  69. SIGNAL Loop
  70.  
  71. EXIT
  72.  
  73. /* Load the RexxUtil library */
  74. LoadRexxUtil:
  75.  IF RxFuncQuery('SysLoadFuncs') THEN
  76.    DO
  77.     IF RxFuncAdd('SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs') THEN
  78.        DO
  79.          SAY "Error: Couldn't load RexxUtil library."
  80.          RETURN 1
  81.        END
  82.        CALL SysLoadFuncs
  83.    END
  84. RETURN 0
  85.  
  86.