home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Windoware
/
WINDOWARE_1_6.iso
/
winutil
/
winder2
/
winders.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-05-15
|
9KB
|
313 lines
/*
Written By: Earl W. Hartsell
Date: 5 - 15 - 92
Name: WINDERS
Version: 2.0
Use: Winders allows the user to choose to automatically run
windows or exit to dos upon startup or reboot.
It allows the user to specify a length of time to
countdown before Windows 3.X is loaded.
Windows may be loaded before the countdown
is complete by pressing one of the modifier keys
([SHIFT], [ALT], or [CTRL]), the user may also
exit to DOS pressing any other key.
The syntax for the command is as follows:
d:\<path>\winders [num] [/d <location>] [/b] [/i] [/n] [/a <args>]
d:\<path>\winders /h | /?
d:\<path>\ is drive and directory path where winders executable is
located.
num is length of pause before loading windows. It must be
first argument and may be range of 1 to 32767 in seconds.
The default pause is 5 seconds. 0 seconds defaults to 5.
/d <location> is to specify drive and directory(s) in which
windows\win.com is located default is c: .
The location is not optional and will generate an error if
not found after the /d. There also must be a space between
the /d and the <location>. If you use the /d option
it must contain the drive and all directories leading to
the \windows\win.com in this form:
drive:\dir1\dir2\...\dirn
The final back-slash is not required.
/b beep on countdown, default no beep.
/i suppress loading windows into screen. Default don't load
intro.
/a <args> are the arguments to be passed to windows. The arguments are
not optional and will generate an error if not found after
the /a. There also must be a space between the /a and the
<args> and multiple arguments must be placed inside
quotes. If you have problems getting this to work
try using full path names on the executables.
/n dont print winders countdown banner.
default print banner.
/v prints out version and copyright information.
/h | /? help screen.
Copyright (c) 1992 by VOLUNTEER SOFTWARE AND CONSULTING.
Permission granted to use, copy, and modify this in any way as long as
the above copyright notice and address remain.
Plese see the file called README for full details.
Windows is a registered trademark of Microsoft Corporation.
*/
#include <stdio.h>
#include <conio.h>
#include <process.h>
#include <time.h>
#include <bios.h>
#define RIGHT 0x01
#define LEFT 0x02
#define CTRL 0x04
#define ALT 0x08
#define HLP 1
#define DOS 2
#define WIN 3
#define null(x) strcpy(x,"")
char copy[] = "Copyright (c) 1992 VOLUNTEER SOFTWARE AND CONSULTING.\n";
char right[] = "Permission is granted to use, copy, and modify as long as\n copyright notice remain.\n";
int main(argc, argv)
int argc;
char *argv[];
{
int pause = 5; /* default pause */
int i = 0, k = 0, j = 0;
char banner = 1; /* print banner flag */
char beep = 0; /* set default beep off */
char arg1[100], arg2[100]; /* arguments to execl */
char intro = 1; /* turn intro screen off */
char cdrive = 1; /* default disk */
time_t start, new; /* long int */
fflush(stdin); /* clear the kbd buffer */
null(arg2); /* argument to pass to windows default none */
if (atoi(argv[1]) > 0) /* take first argument as number */
{
j = 2;
pause = atoi(argv[1]);
}
else
{
j = 1;
pause = 5;
}
for (; j < argc; j++)
{
switch (argv[j][1])
{
case 'v':
clrscr();
fprintf(stderr,"\n");
fprintf(stderr,"\t\t\tWINDERS VERSION 2.0\n");
fprintf(stderr,"%s",copy);
fprintf(stderr,"%s",right);
fprintf(stderr,"\n");
case 'h': case '?':
fprintf(stderr,"\t\t\tWINDERS HELP\n");
fprintf(stderr,"%s [num] [/d location] [/b] [/a args] [/n] [/i]\n",argv[0]);
fprintf(stderr,"%s /h | /? for this help screen.\n",argv[0]);
fprintf(stderr,"%s /v for version and copyright information.\n\n",argv[0]);
fprintf(stderr,"num is duration of pause. default 5. Num must be first argument.\n");
fprintf(stderr,"/d location is to specify drive and directory(s) in which \\windows\\win.com \n");
fprintf(stderr," is located default is c: \n");
fprintf(stderr,"/b is beep on countdown, default no beep.\n");
fprintf(stderr,"/i is to suppress loading windows intro screen. Default do not show intro.\n");
fprintf(stderr,"/n dont print winders countdown banner. Default is print banner.\n");
fprintf(stderr,"/a is the argument(s) to be passed to windows.\n");
fprintf(stderr,"/h and /? print out this screen.\n\n");
fprintf(stderr,"Pressing [SHIFT], or [ALT], or [CTRL] during the countdown\n");
fprintf(stderr,"will cause Windows to load that instant.\n");
fprintf(stderr,"Pressing any other key will cause Winders to exit to DOS.\n");
fprintf(stderr,"\n");
exit(HLP);
break; /* help screen */
case 'd':
if ( argv[j+1] == NULL || argv[j+1][0] == '/' )
{
fprintf(stderr,"\n");
fprintf(stderr,"%s: error in location option no arguments found.\n",argv[0]);
fprintf(stderr,"%s: option /d ignored.\n",argv[0]);
delay(2000);
/* error no argument found to pass to windows */
}
else
{
cdrive = 0;
strcpy(arg1, argv[++j]);
}
break;
case 'n':
banner = 0; /* dont print countdown banner */
break;
case 'b':
beep = 1; /* set beep on */
break;
case 'i':
intro = 0; /* turn on intro screen */
break;
case 'a':
if ( argv[j+1] == NULL || argv[j+1][0] == '/' )
{
fprintf(stderr,"\n");
fprintf(stderr,"%s: error in argument option no arguments found.\n",argv[0]);
fprintf(stderr,"%s: option /a ignored.\n",argv[0]);
delay(2000);
/* error no argument found to pass to windows */
}
else
{
strcpy(arg2, argv[++j]); /* pass arguments */
}
break;
default:
fprintf(stderr,"\n");
fprintf(stderr,"%s: Argument %s not recognized\n",argv[0],argv[j]);
fprintf(stderr,"%s: Argument ignored.\n",argv[0]);
delay(2000);
}
}
k = keyhit(); /* check and see if key has already been selected */
if (k == 1) Winf(arg1,arg2,cdrive,intro);
if (k == 2) Dosf(); /* exit to dos if key is pressed */
clrscr(); /* clear screen */
if (banner)
{
printf("\t\t\t╔═══════════════════════════╗\n");
printf("\t\t\t║ Winders Countdown ║\n");
printf("\t\t\t╚═══════════════════════════╝\n\n");
}
printf("\t\t Loading Windows in %d seconds.\n",pause);
printf("\t Press [SHIFT], or [ALT], or [CTRL] to load Windows now.\n");
printf("\t\t Press any other key to exit to DOS.\n"); /* print banner */
printf("\t\t\t\t Counting");
start = time(NULL); /* get initial time in seconds */
for (i=1 ;(i <= pause && !k);i++)
{
new = time(NULL); /* get new time */
while(new - start == 0) /* start time = new time second not elapsed */
{
new = time(NULL); /* get new time again */
k = keyhit(); if (k) break;
}
if (k == 1) Winf(arg1,arg2,cdrive,intro);
if (k == 2) Dosf(); /* exit to dos if key is pressed */
if (new - start != 0)
{
if (beep)
printf("\a.");
else
printf(".");
}
start = new;
}
Winf(arg1,arg2,cdrive,intro);
return (0); /* keeping the compiler happy */
}
/*
keyhit- function returns 0,1, or 2 depending on the key pressed
0 - if no key has been pressed
1 - if SHIFT, CTRL, or ALT has been pressed
2 - if a key other than the ones above has been pressed
*/
int keyhit(void)
{
int modifiers;
modifiers = bioskey(2);
if (modifiers)
{
if (modifiers & RIGHT) return(1);
if (modifiers & LEFT) return(1);
if (modifiers & CTRL) return(1);
if (modifiers & ALT) return(1);
}
if (bioskey(1)) return(2);
return(0);
}
/* Dosf - return to DOS and clear screen */
Dosf(void)
{
fflush(stdout);
clrscr();
exit(DOS);
return(DOS); /* it will never make it here but it will keep the compiler */
/* happy. */
}
/* Winf - execute win.com and pass arguments to it.
arg1 -
arg2 - arguments passed to WIN.COM
cdrive - 0 use drive specified
1 use default drive
intro - 0 will by pass Windows intro using command win :
1 (default) Will show intro screen
Note: execl was used in the hope that the progam would be
cleared from memory and not take up any space in Windows.
*/
Winf(arg1, arg2, cdrive, intro)
char arg1[], arg2[];
char cdrive, intro;
{
char cmd_part2[30];
strcpy(cmd_part2,"\\windows\\win.com"); /* win.com must be in */
/* \windows\win.com */
printf("\n\t\t\t Loading Windows...");
if (cdrive)
{
strcpy(arg1,"c:"); /* default to c drive */
strcat(arg1,cmd_part2);
}
else
strcat(arg1,cmd_part2); /* use drive specified */
if (intro) /* to show into or not to show intro */
execl(arg1,"win",":",arg2,NULL);
else
execl(arg1,"win",arg2,NULL);
return(WIN);
}