home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cenvi23.zip / ISRUN.CMD < prev    next >
OS/2 REXX Batch file  |  1995-03-28  |  1KB  |  36 lines

  1. EXTPROC CEnvi2
  2. //*****************************************************************
  3. //*** IsRun.cmd - CEnvi2 program to check if process is running. ***
  4. //*** ver.3        Return errorlevel 0 if running, else 1       ***
  5. //***              Search based on name, not directory or       ***
  6. //***              extension.                                   ***
  7. //*** Example: IsRun PULSE                                      ***
  8. //*****************************************************************
  9.  
  10. main(argc,argv)
  11. {
  12.    if ( argc != 2 ) {
  13.       printf("Must supply process name.\n");
  14.       return 1;
  15.    }
  16.  
  17.    ProcessName = argv[1];
  18.  
  19.    PList = ProcessList();
  20.    assert( NULL != PList );
  21.    Count = 1 + GetArraySpan(PList);
  22.    for ( i = 0; i < Count; i++ ) {
  23.       FileName = PList[i].name;
  24.       Parts = SplitFileName(FileName);
  25.       if ( !stricmp(Parts.name,ProcessName)
  26.         || !stricmp(FileName+strlen(Parts.dir),ProcessName) ) {
  27.          printf("%s is running.\n",ProcessName);
  28.          return 0;
  29.       }
  30.    }
  31.  
  32.    printf("%s is not running.\n",ProcessName);
  33.    return 1;
  34. }
  35.  
  36.