Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Dating a log

Nov
31
0
I managed to write a short script to run chkdsk as a scheduled task and to write a log of the result, but could not see a way to date the log. Can anybody see a way to do this via cmd or otherwise? I bought a copy of Take Command in case that would reveal a way of achieving this, but if it is there it will not come without much study. The script is:
C:\WINDOWS\system32\cmd.exe /C chkdsk V: /f /X >> "d:\chkdsklogs\chkdsk.rtf"
 
I notice that you deal with - according to its extension - a rich text format file. Some of my comments depend on that.

You can just use the modification ("write") timestamp of the file itself. If you use the Properties display from MS Word, the timestamps displayed are those of the file: creation and access of the specific copy you are viewing (differs in case the file has been copied from those of the original), modification (same as the original). They are not from some hidden part of the file.

If you do not want to depend on the file's external properties, thus want to record the timestamp in its content, the primary issue is file format.

Inserting a timestamp into a plain text file is, per se, simple:
echo %_date %_time >>! history.log
(Note the exclamation mark ! following the redirection symbol - I use noclobber mode, this overrides the need to have a file to which to concatenate.)

To insert the timestamp into the content of an RTF file, you need to have some knowledge of RTF encoding so that you can insert the text in some appropriate part of the file in a format that is not hidden. This is not necessarily at the beginning or end, it may need to be somewhere in the middle. Sorry, I cannot help with that...
 
I managed to write a short script to run chkdsk as a scheduled task and to write a log of the result, but could not see a way to date the log. Can anybody see a way to do this via cmd or otherwise? I bought a copy of Take Command in case that would reveal a way of achieving this, but if it is there it will not come without much study. The script is:
C:\WINDOWS\system32\cmd.exe /C chkdsk V: /f /X >> "d:\chkdsklogs\chkdsk.rtf"

How did you want to "date" the log:

1) Change the time stamp of the log file
2) Embed the date in the name of the log file
3) Embed the date somewhere inside the log file

(Any of those can be easily done with Take Command.)
 
Thanks Steve and rconn for your comments.

I wish to append the date and preferably also the time to the log file. My chkdsk log accumulates the results of chkdsk running as a scheduled task, and it would be helpful when reviewing the log and see when any errors were found.

I could not get Steve's script to work on its own, but with a bit of tweaking came up with the following Cmd script to append the date and time to the log:

@Echo %date% %time% >>"d:\chkdsklogs\chkdsk.log"

That is a big step forward, and now I should like to be able to add it to my scheduled task. I tried merely tagging it onto the end of my existing scheduled task as follows, but that did not work:

C:\WINDOWS\system32\cmd.exe /C chkdsk K: /f /X >> "d:\chkdsklogs\chkdsk.log" @Echo %date% %time% >>"d:\chkdsklogs\chkdsk.log"

I could of course set up a second scheduled task to run after chkdsk has run, but with around 20 drives and scheduled tasks, that would be a messy solution - it would add another 20 or so scheduled tasks.

Is there any way I can tag my dating script onto my existing scheduled task? Can it be done directly by extending the script, or can I do it by writing the 2 scripts into a batch file?

I am afraid I do not yet have enough experience of the dos language to progress this except by groping my way around and often getting nowhere.

I should be most interested to achieve the result with Take Command, but would rather set it up in dos first, and then see how I can do it in Take Command.
 
Ps Hooray! I have succeeded in writing a batch file that does the business, and then added it as a scheduled task, which gives me a route to where I wish to go. However, I should be most interested to read any answers that you can offer answers to the other questions that I raised in my last post.

The batch file is very simple:
@Echo %date% %time% >>"d:\chkdsklogs\chkdsk.log"

C:\WINDOWS\system32\cmd.exe /C chkdsk K: /f /X >> "d:\chkdsklogs\chkdsk.log"

@Echo %date% %time% >>"d:\chkdsklogs\chkdsk.log"

And the the task was added as a scheduled task using the add task wizard in xp pro.
 
Sorry, I thought you are asking a question about a .BTM file executed by TCMD/TCC, not a .bat/.cmd file run by CMD! You CAN run TCC batch files as a scheduled task, you know. Several post in the recent past show how.
 
Thanks Steve.

Is it necessary to have Take Command running for windows to run a TCC batch file as a scheduled task, or can windows do it by itself?
 
Thanks Steve.

Is it necessary to have Take Command running for windows to run a TCC batch file as a scheduled task, or can windows do it by itself?
TCMD is not necessary, but TCC is. I have scheduled tasks with command lines like "g:\tc15\tcc.exe /c some_file.btm". It is possible (I don't know for sure) that if *.BTM is associated with TCC, you could just specify the BTMfile's name.
 
I was trying to think of something funny to add to this thread, but, as the tree said to the lumberjack, "I'm stumped!"

Joe
 
I was trying to think of something funny to add to this thread, but, as the tree said to the lumberjack, "I'm stumped!"

Oh dear me Joe! We'll have to spruce up the humor in this thread or our elders and betters will be upset. On the other hand, perhaps we should get this thread back onto topic, it's getting hard to cedar wood for the trees...
 
Actually I think we have exhausted the original topic before my first feeble attempt at humor... though it started an avalanche!
 

Similar threads

Back
Top