.bat : dupe <Enter> key

J

John A Grandy

in a .bat file .... how to duplicate the effect of presing the <Enter> key
....

for example: i want the nt "time" command to print the time to the batch
file's log-file ... but "time" always prompts the user to enter the new time
.....
 
M

Mark V

John A Grandy wrote in
in a .bat file .... how to duplicate the effect of presing the
<Enter> key ...

for example: i want the nt "time" command to print the time to
the batch file's log-file ... but "time" always prompts the user
to enter the new time ....

What OS?
time /? may reveal the "/t" switch to you
echo time /t >>file
same for DATE

echo | time | find "Current" >>file
echo/| time | find "Current" >>file

Your OS may have %time% and %date% system created environment values
echo %time% >>file
 
J

John A Grandy

well .......... right now, i need to do this on w2k svr and wxp pro ....

i'm re-directing the entire output of the batch file to another file ....
 
J

Joe Richards [MVP]

You can use a blank line sometimes to specify an <ENTER>

For the time command you should be able to do time /t and skip the enter.

Also look in the reskit for the NOW command
 
G

guard

for example: i want the nt "time" command to print the time to the batch
file's log-file

The (FREE) Advanced NT/2K/XP Command Library (ntlib.cmd) provides the
..Mount/\Commands ".DateEcho" and ".TimeEcho", which CONSISTENTLY
echo the date or time under NT/2K/XP/K3 using only what is
available in a standard install of each platform.
*******
C:\GuardPost>%.DateEcho% Optional Message
[Mon 09/01/2003] Optional Message
C:\GuardPost>%.TimeEcho% Optional Message
[05:18:51] Optional Message

-OR-

C:\GuardPost>%.TimeEcho% Job Started >> logfile.txt

C:\GuardPost>%.TimeEcho% Working... >> logfile.txt

C:\GuardPost>%.TimeEcho% Job Finished >> logfile.txt

C:\GuardPost>type logfile.txt
[05:30:19] Job Started
[05:30:27] Working...
[05:30:36] Job Finished

*******

Related commands:


[The following echo to STDOUT]

__________________________________________________________LogDateEcho
20030901 Optional message from LogDateEcho
__________________________________________________________LogTimeEcho
051853 Optional message from LogTimeEcho
__________________________________________________________dtEcho
[Mon 09/01/2003 05:18:53] Optional message from dtEcho
__________________________________________________________ldtEcho
20030901 051853 Optional message from ldtEcho


*******

[The following echo to STDERR]

__________________________________________________________dErrEcho
[Mon 09/01/2003] Optional error message from dErrEcho
__________________________________________________________ldErrEcho
20030901 Optional error message from ldErrEcho
__________________________________________________________tErrEcho
[05:18:53] Optional error message from tErrEcho
__________________________________________________________ltErrEcho
051853 Optional error message from ltErrEcho
__________________________________________________________dtErrEcho
[Mon 09/01/2003 05:18:53] Optional error message from dtErrEcho
__________________________________________________________ldtErrEcho
20030901 051855 Optional error message from ldtErrEcho

*******
All of the above are part of the .[Value]Echo Series of .Mount/\Commands.
See the .ValueEcho Page for details
(http://TheSystemGuard.com/MtCmds/ValueEcho)

*******
Notes:

1. .Mount/\Commands are constructed using ONLY builtin
commands common to all four platforms (NT/2K/XP/K3).
2. .M/\C's are NOT case sensitive. Mixed case is used
for Visual Clarity only.
3. ntlib.cmd provides over 100 resources to assist with
writing and documenting cross-platform scripts,
including 57 fully functional .Mt/\Cmds.
You can obtain it (for FREE) at (http://ntlib.com).

*******

-tsg
____________________________________________________________
TheSystemGuard.com | BoomingOrFuming.com | MountCommands.com
Free and "Almost Free" Knowledge for Windows System Admins!
 
H

Herb Martin

On way is to build a text file with a bunch of CR/LF in it
and then when you run a command that needs the ENTER
key redirect from that file.

Trick is to build one with enough to get your through EACH
command (you get to re-start on the next command.)

I use this mostly for answering "N<return>" to "Do you want
to overwrite this file?"

I have 30,000 lines of just "N<return>" in a text file.
 
T

Tom Lavedas

Among the other correct suggestions, the most common
solution from antiquity (i.e. pre Windows DOS) that does
not require a separate file (system creates and deletes
them):

echo.| time >> log.txt

Though in Win NT/2000/XP the /T switch may be a better
solution. However, Win 95/98/Me still require this
approach and some older utilities that may still be in use
may also benefit from this approach.

Note that even in the OS's that provide the /T switch,
redirection may still be desired as it creates a 24 hour
clock format with fractions of a second. The /T option
creates a 12 hour clock (for locales with this option)
that is truncated to minutes. Depending upon what is
desired, one appoach may be more useful than the other.

Tom Lavedas
===========
-----Original Message-----
in a .bat file .... how to duplicate the effect of
presing the said:
....

for example: i want the nt "time" command to print the time to the batch
file's log-file ... but "time" always prompts the user to
enter the new time
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top