Help with DOS batch scripting

RagnaroK

Must be dreaming...
Joined
27 Apr 2002
Messages
673
Hi,
Just wondering if the following is possible:

If I were to put this into a batch file, for example:
Code:
@echo off
echo Copy done @
date /t
time /t

The following would be displayed onscreen correct?
Code:
Copy done @
Mon 01/01/0001
00:01 AM

Now what I want to do is to get the above info displayed onscreen like this instead:
Code:
Copy done @ Mon 01/01/0001 00:01 AM
I want it on the one same line instead of the three lines? Is it possible? Thanks and any input is appreciated. :D
 
This should do what you need to do:

@ECHO OFF
set timestamp=%date% %time%
echo Copy done @ %timestamp%

Sample output:

Copy done @ Sun 01/18/2004 22:33:16.29
 
Yes that looks right the echo command will display the message that follows the echo
 
If you are not doing anything between the time recorded and the time displayed you could just do:

@ECHO OFF
Copy done @ %date% %time%
 
Just what I needed. Thank you very much.
I'm interested in learning more of such programming, do you know where I can do that?

Edit:
Umm, got a problem. Are the %date% and %time% commands OS specific? Because I tested the commands on my WinXP system at home, and they worked fine, but I tried them on a WinNT system, and it doesn't show the date and time. :(
 
I think that those commands will only work on Windows 2000 and above. I haven't used an NT machine in a couple of years so I have dumped most of what I remember about it.
 

Members online

No members online now.

Latest profile posts

Also Hi EP and people. I found this place again while looking through a oooollllllldddd backup. I have filled over 10TB and was looking at my collection of antiques. Any bids on the 500Mhz Win 95 fix?
Any of the SP crew still out there?
Xie wrote on Electronic Punk's profile.
Impressed you have kept this alive this long EP! So many sites have come and gone. :(

Just did some crude math and I apparently joined almost 18yrs ago, how is that possible???
hello peeps... is been some time since i last came here.
Electronic Punk wrote on Sazar's profile.
Rest in peace my friend, been trying to find you and finally did in the worst way imaginable.

Forum statistics

Threads
62,015
Messages
673,494
Members
5,621
Latest member
naeemsafi
Back