Category : Utilities for DOS and Windows Machines
Archive   : SETEXEC.ZIP
Filename : SETEXEC.C

 
Output of file : SETEXEC.C contained in archive : SETEXEC.ZIP
/* This program is meant to help people who run multiple autoexec.bat
* files. If you depress a number -- 1 - 9 -- while the autoexec is execing,
* it will set a corresponding dos errorlevel.
*
* You would run this program in your autoexec, check for the errorlevels,
* and branch to an appropriate label to run a particular a/exec setup.
* This technique does not address the stickier problem of multiple
* config.sys files, but it may be helpful to someone.
* -- Dan Goldberg. Turbo C v2.0, 8/91 */



#include
#include
#include


/* delay function */
void delay(seconds)
unsigned int seconds;
{
long dtime;

dtime = time(NULL) + seconds;

while (dtime != time(NULL));
}

int c; /* for switch test */

main(int argc, char *argv[])

{

int e = atoi(argv[1]); /* make SURE you get an integer value.*/

if ( (argc != 0) && (e < 0) || (e > 9) ){
/* if command line value is entered, check its range (must be 1-9) */

printf("Value must be between 1 and 9.\n");
puts("0");
exit(0);
}

if (e != 0){
printf("%d",e);
exit(e);

}
/* if no command line value is entered, get one */
if (e == 0){
printf ("\nEnter an errorlevel/label to set ==> ");

/* timeout so autoexec does not wait forever, after all it is
* the autoexec file */
delay(2);
}
/* if no key is struck, set dos errrorlevel to 0 */
if (kbhit() == 0){
puts("0");
exit(0);
}

else{

switch ( c = getch() ){
/* else, set errorlevel as requested */
case '9': puts("9"); exit(9);
case '8': puts("8"); exit(8);
case '7': puts("7"); exit(7);
case '6': puts("6"); exit(6);
case '5': puts("5"); exit(5);
case '4': puts("4"); exit(4);
case '3': puts("3"); exit(3);
case '2': puts("2"); exit(2);
case '1': puts("1"); exit(1);
default : puts("default: 0"); exit(0);
}

}


}


  3 Responses to “Category : Utilities for DOS and Windows Machines
Archive   : SETEXEC.ZIP
Filename : SETEXEC.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/