Discussion Locked

Batch scripts

0 helpful
10 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

G'day,

I have a few commands placed in autoexec.bat to append the date and time into a startup log. These will be used to match up shutdown time and dates to see if windows crashes without adding to the log.

The problem are the commands in autoexec.bat:
date >> c:\windows\startup.txt
time >> c:\windows\startup.txt
When autoexec.bat runs, these command require a keyboard command to continue running autoexec.bat (e.g. return). Is there a line of code I can add , such as "Enter", to make sure autoexec.bat doesn't require user intervention to continue running.

The other problem is that windows doesn't shutdown properly, it automatically runs disk doctor in dos. Is there a way to disable this, or set a menu in autoexec.bat to choose between having it off or on, with the default being off?

Thankyou in advance for help.

Cheers.

10 replies

by zalog

Pipe your commands using the echo command. The command would be 'echo. | date >> c:\windows\startup.txt' and 'echo. | time >> c:\windows\startup.txt'.
Also not there is a '.' after each echo command. This causes and enter to be passed to the dateor time command.

by zalog

The second to last sentence should read: "Also NOTE there is a '.' and a vertical bar after each echo command."

by mphoffar

I beleive all your need to do is modify the date and time commands with a /T so you commands will look like this

date /T >> c:\windows\startup.txt
time /T >> c:\windows\startup.txt

What that switch does is displays the current date and/or time without prompting for a new one.

Mark

by rucinski

Start -> Run, and type in MSCONFIG. On the GENERAL tab, click ADVANCED. Check Disable Scandisk.

There is a better method to create a log file of dates and times using just a batch file; it allows you to set evvironment variables for day, date, month and year (Both two and four digit.)

The problem is I have misplaced the technique. I'll post a comment later tonight.

Bob

by rucinski

I can't get the "T" switch to work under DOS (Win98 4.10.2222.)

PC Mag and Neil Rubenking in particular have batch file techinques to parse the environment strings.

Hint: Set the attribute on TimeKeep.log to hidden.

Bob

@Echo Off

Ver|Time|Find "Current">$TTemp.bat
Echo Set CTime=%%3>Current.bat
call $TTemp.bat

Ver|Date|Find "Current">$TTemp.bat
Echo Set CDate=%%3 %%4>Current.bat
Call $TTemp.bat

Del Current.bat>nul
Del $TTemp.bat>nul

Echo %CDate% %CTime% >Timekeep.log

by rucinski

Correction: The last line of the batch file should be:

Echo %CDate% %CTime% >>Timekeep.log

But you knew that.

Bob

This discussion is closed to new replies.