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

  1. /********************************************************************
  2.  *** WinSpawn.cmd - Command line use of the WinSpawn() routine to ***
  3.  *** ver.2          spawn Windows commands from OS/2 to a Windows ***
  4.  ***                session running WinSpawn.cmm using CEnvi2 for  ***
  5.  ***                Windows.                                      ***
  6.  ********************************************************************/
  7.  
  8. '@echo OFF'
  9. VALUE(WINSPAWN_CMD,ARG(1),'OS2ENVIRONMENT')
  10. 'CEnvi2.exe %0.cmd %1 %2 %3'
  11. 'SET WINSPAWN_CMD='
  12. SIGNAL CENVI_EXIT
  13.  
  14. #include <WinSpawn.lib>
  15.  
  16. main(argc,argv)
  17. {
  18.    if ( argc < 3 ) {
  19.       Instructions();
  20.       exit(EXIT_FAILURE);
  21.    }
  22.  
  23.    PipeName = argv[1];
  24.    Command = WINSPAWN_CMD + 1 + strlen(PipeName);
  25.    if ( !stricmp(Command,"EXIT") ) {
  26.       WinSpawn(PipeName,WIN_SPAWN_EXIT,NULL);
  27.    } else {
  28.       if ( !strnicmp(Command,"WAIT",4) ) {
  29.          Wait = True;
  30.          Command += 5;
  31.       } else {
  32.          Wait = False;
  33.       }
  34.       WinSpawn(PipeName,Wait ? WIN_SPAWN_WAIT : WIN_SPAWN, Command);
  35.    }
  36. }
  37.  
  38. Instructions()
  39. {
  40.    puts("\a")
  41.    puts("WinSpawn.cmd - Pass spawn command to Windows session's WinSpawn.cmm")
  42.    puts("")
  43.    puts("USAGE: WinSpawn <PipeSpec> <Command>")
  44.    puts("")
  45.    puts("WHERE: PipeSpec: unique name that CEnvi2 for Windows WinSpawn.cmm uses")
  46.    puts("       Command: Any Spawn() command passed on to windows.  If command is")
  47.    puts("                EXIT then simple end the WinSpawn.cmm session.  If the")
  48.    puts("                first parameter is WAIT then waits for spawn command to")
  49.    puts("                finish.")
  50.    puts("")
  51.    puts("EXAMPLES:")
  52.    puts("   WinSpawn Foo clock.exe")
  53.    puts("   WinSpawn Foo CEnvi2 #include \"WinTools.lib\" ShowWindow(\"Clock\",SW_MINIMIZE)")
  54.    puts("")
  55.    puts("NOTE: You must already have started WinSpawn.cmm in a Windows session with")
  56.    puts("      a unique PIPESPEC name, such as:")
  57.    puts("        start /WIN C:\\CEnviW\\CEnviW.exe C:\\CENVI2\\WinSpawn.cmm FOO 2000")
  58. }
  59.  
  60. CENVI_EXIT:
  61.  
  62.