home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / s / snip1292.zip / SHEL2DOS.C < prev    next >
C/C++ Source or Header  |  1991-12-05  |  834b  |  41 lines

  1. /*
  2. **  SHEL2DOS.C - Shell to DOS from a running program
  3. **
  4. **  Original Copyright 1989-1991 by Bob Stout as part of
  5. **  the MicroFirm Function Library (MFL)
  6. **
  7. **  This subset version is hereby donated to the public domain.
  8. */
  9.  
  10. #include <stdlib.h>
  11. #include <string.h>
  12.  
  13. int shell_to_DOS(void)
  14. {
  15.       char *comspec, prompt[256];
  16.  
  17.       comspec = getenv("COMSPEC");
  18.       if(comspec == NULL)
  19.             comspec = "COMMAND.COM";     /* Better than nothing... */
  20.  
  21.       sprintf(prompt, "PROMPT=[Type EXIT to return to program]\r\n%s",
  22.             getenv("PROMPT"));
  23.  
  24.       putenv(prompt); 
  25.  
  26.       return spawnlp(0, comspec, NULL, "/p", NULL);
  27. }
  28.  
  29. #ifdef TEST
  30.  
  31. #include <stdio.h>
  32.  
  33. void main(void)
  34. {
  35.       int retval = shell_to_DOS();
  36.  
  37.       printf("shell_to_DOS() returned %d\n", retval);
  38. }
  39.  
  40. #endif
  41.