home *** CD-ROM | disk | FTP | other *** search
- #include <stdlib.h>
- #include <stdio.h>
- #include <conio.h>
- #include <dos.h>
- #include <string.h>
-
- /*********************************************************
-
- Usage: put in CONFIG.SYS
-
- CALL=[path]NPWAIT.EXE [-cCOMMAND] [-wWAIT_TIME] [-r]
-
- optional switches:
-
- -cCOMMAND Tells NPWAIT what command to run if a key is hit.
- Usually, you would want it to run CMD.EXE, but you
- can use this switch to tell it the right drive and path.
- If you use something other than CMD.EXE, do not
- attempt to pass arguments to the program you run.
- default value = C:\OS2\CMD.EXE
- example: -cE:\OS2CMDS\CMD.EXE
-
- -wWAIT_TIME Tells NPWAIT how long to count down, in seconds.
- default value = 10
- example: -w20
-
- -r Tells NPWAIT to resume countdown when you exit the
- COMMAND shell CMD.EXE.
- default value = Do not resume countdown, exit NPWAIT immediately.
-
- EXAMPLE:
-
- The following command will run wait 20 seconds, and run
- the program D:\OS2\CMD.EXE if a key is pressed. When the user
- types EXIT at the command line, it will continue on with its
- countdown until it reaches 0. Then it will continue with
- CONFIG.SYS.
-
- CALL=C:\OS2UTIL\NPWAIT.EXE -cD:\OS2\CMD.EXE -w20 -r
-
- **********************************************************/
-
- int main(int argn, char *argc[])
- {
- int i;
- unsigned wait_duration = 10;
- char command_string[240] = "c:\\os2\\cmd.exe";
- char wait_string[40];
- int return_flag = 0;
- char *waiting = "Waiting...%d";
- char *instructions = "Press any key to exit to command line";
-
- if (argn > 1) {
- for(i=1;i<argn;i++) {
- if ((argc[i][0] == '-') || (argc[i][0] == '/')) {
- switch(argc[i][1]) {
- case 'w':
- case 'W':
- strcpy(wait_string,&argc[i][2]);
- wait_duration = atoi(wait_string);
- break;
- case 'c':
- case 'C':
- strcpy(command_string,&argc[i][2]);
- break;
- case 'r':
- case 'R':
- return_flag = 1;
- break;
- }
- }
- }
- }
-
- clrscr();
- gotoxy(40-strlen(instructions)/2,2);
- printf(instructions);
- for (i=wait_duration;i>0;i--) {
- gotoxy(40-strlen(waiting)/2,10);
- clreol();
- printf(waiting,i);
- sleep(1);
- if (kbhit()) {
- clrscr();
- getch();
- system(command_string);
- clrscr();
- if (! return_flag)
- return(0);
- gotoxy(40-strlen(instructions)/2,2);
- printf(instructions);
- }
- }
- clrscr();
- return(0);
- }
-
-