[comp.os.msdos.programmer] Using DOS to create a logon

jad43082@uxa.cso.uiuc.edu (Jason Arthur DeHaan) (10/23/90)

I have an IBM PC running MS DOS 3.2.  I was wondering if there is anyone out
there that can help me solve a little problem with a batch file that I have
attempted to create.  Its purpose is to record the name of the user, as well
as the time and date of signon.  Using temporary files, I've managed to 
sucessfully do this with one exception.  When I write the time to a file, the 
time command prompts the user to "Enter new time".  I've hidden this and
issued a "Press RETURN to continue" command to the user, but this is both 
annoying and dangerous.  Is there any way to include control commands (such
as ^M) in the batch file.  When I try to do this, the computer executes the 
command immediately, but does not store one in the batch file.

    Thanks for any help you can give

    Jason DeHaan  jad43082@uxa.cso.uiuc.edu

changw@athena.ecs.csus.edu (Weide Chang) (10/23/90)

jad43082@uxa.cso.uiuc.edu (Jason Arthur DeHaan) writes:
>I have an IBM PC running MS DOS 3.2.  I was wondering if there is anyone out
>there that can help me solve a little problem with a batch file that I have
>attempted to create.  Its purpose is to record the name of the user, as well
>as the time and date of signon.  Using temporary files, I've managed to 
>sucessfully do this with one exception.  When I write the time to a file, the 
>time command prompts the user to "Enter new time".  I've hidden this and
>issued a "Press RETURN to continue" command to the user, but this is both 
>annoying and dangerous.  Is there any way to include control commands (such
>as ^M) in the batch file.  When I try to do this, the computer executes the 
>command immediately, but does not store one in the batch file.

Redirection works now in DOS. So you can have a text file that contains
a CR/LF and add to the time command line as:

			time < cr_lf.txt

and the ^M will be sent to the needed time prompt as if typed in.
Example:
		login.bat :

			time < cr_lf.txt
			... (other commands)

		cr_lf.txt :
			    (just an empty line, ^M is there)

So CR/LF will be automaticly entered at the time command line and you
make the login.bat bypass the time prompt.
This is also helpful to erase all files from a diskette that an app-
lication prompt users to put in a formatted old diskette, and call
up the system's DOS to do a del a:*.* < yes.txt, where yes.txt 
contains only a 'y' and a ^M to satisfy the 'Are you sure (Y/N)?' prompt.

n8541751@unicorn.wwu.edu (Where there is darkness, light) (10/23/90)

jad43082@uxa.cso.uiuc.edu (Jason Arthur DeHaan) writes:

>... command prompts the user to "Enter new time".  I've hidden this and
>issued a "Press RETURN to continue" command to the user, but this is both 
>annoying and dangerous.  Is there any way to include control commands (such
>as ^M) in the batch file.  When I try to do this, the computer executes the 
>command immediately, but does not store one in the batch file.

You can do this by redirecting both the input and output for the
time command, like this:

  time <testfile.doc >>when.rec

Then create a file called testfile.doc that just has a cr/lf combination
inside it, and nothing else.  The time will be concatenated to when.rec.

The effect will be the same as if the user had pushed return, and nothing
will show on the screen, provided the echo off command has been used
previously in the batch file.

You could also make the file from which input is redirected be a hidden
file and things will work the same.

Incidentally, you are probably better off writing a program in C or
some other language and calling it from your autoexec.bat file to do this,
batch files by themselves aren't particularly well-suited to this application.

Hope this helps...

-- 
Kriston M. Bruland        |    . .         . .      . . .      .       . .
n8541751@unicorn.wwu.edu  |    .   .     . .        .        . .       .   .
8541751@nessie.wwu.edu    |    .             .         .     .   .     .