|
Answer» I got a batch that log the windows startup time and date. But recently, I receive a motherboard without CMOS design inside. So everytime I power off the board, the time is reset. so the date and time always overwritten.(only one line of time log)
How do I make the batch file always write different from last power off data?
example: 1st power on: write 1 then system power off 2nd power on: write 2 then system power off 3rd power on: write 3 .... so on
I don't know if it is posible without CMOS.....
the original command line is (stored it as log.bat at windows startup folder): @echo off cls echo Windows Started %date% %time% >> c:\startup.txt
Could you tell US your OS?windows XPalright, let me get this straight, everytime you boot up you want to save the current time and date to a txt document.
is that it?yes.. so i can check is that a "loss/miss" boot.. i set a hardware timer to do reboot (AC on off) for 100cycles but my motherboard do not have CMOS,the data and time will reset when AC loss. so the time and date is same at every boot.Why not just get a new CMOS BATTERY?alrighty, here's the code.
Code: [Select]@echo off if Exist C:\startup.txt ( echo %date% %time% > C:\startup.txt ) Else ( echo %date% %time% > C:\startup.txt )
just save it as a BAT file and then goto Scheduled Tasks and add this as a scheduled task and set it for "When my computer starts" so it can run right at boot up.
Hope this helps ,Nick(macdad-)i save the text u given as power.bat at windows desktop then create a new schedule task and point this bat file then i power off and on my machine but i didn't find any log at C: it should be a startup.txt at C: Am I doing in correct way?well, i read the command u given carefully. I think it is working same with my previous command(i put it at windows startup folder previously) i guess the log will have only one line no matter how many TIMES i turning on and off my machine. because my machine will START the date and time 1/jan/07 00:00:00 everytime it power on from AC loss. because no battery I need to work it another way round... the bat should create a new line instead of overwrite it.... am i right???Quote @echo off if Exist C:\startup.txt ( echo %date% %time% > C:\startup.txt ) Else ( echo %date% %time% > C:\startup.txt )
The if and the else need to be on the same logical line.
Quotei guess the log will have only one line no matter how many times i turning on and off my machine
There is no difference traveling the if path or the else path. This may help:
Code: [Select]@echo off if Exist C:\startup.txt ( echo %date% %time% >> C:\temp\startup.txt ) Else ( echo %date% %time% > C:\temp\startup.txt )
Good luck.
|