|
Answer» An old Laptop is missing the battery. Runs fine while plugged in. Left without power for a few days and the time is way off. Really Way off. How can i put a simple batch file the will reset the date if it is earlier than, say, March 15, 2010. It would be OK to just SET it to March 15, 2010 and make a beeping noise ti let me know. Maybe I could do this myself, but it would take me a week. But some you people does this sort of thing during lunch without letting your coffee get cold. Pretty please!
PS I know about http://support.microsoft.com/kb/199030 but this is not an issue here, I just need a simple batch to fix the date and beep me on a old XP machine, not Vista or Windows 7.Spent some time trying to make a script work with this, but I GAVE up. VBScript and JScript make setting the date and time ridiculously hard. (and I couldn't get the WMI methods to work).
So I resorted to a VB6 program I tried the script first to avoid using an executable. oh well.
just a single module actually, you could probably make something similar with QuickBASIC...
Code: [Select]Option Explicit
Sub Main() Dim latestdate As Date Dim dateparts() As String
Dim gotyear As Integer, gotmonth As Integer, gotday As Integer
If Command$ <> "" Then dateparts = Split(Date, " ") If UBound(dateparts) >= 0 Then gotyear = Val(dateparts(0)) If UBound(dateparts) >= 1 Then gotmonth = Val(dateparts(1)) If UBound(dateparts) >= 2 Then gotday = Val(dateparts(2)) End If End If End If Else gotyear = 2010 gotmonth = 3 gotday = 1
End If latestdate = DateSerial(gotyear, gotmonth, gotday)
If Now < latestdate Then Date = DateSerial(2010, 3, 1) Beep MsgBox "System Date has been reset to " & FormatDateTime(Now) End If
End Sub
-the source files are included as well.
[recovering disk space - old attachment deleted by admin]
Quote from: Geek-9pm on April 05, 2010, 05:10:05 PM I just need a simple batch to fix the date and beep me on a old XP machine.
Sorry, my recent batch with net time /? did work correctly.
Try this:
http://support.microsoft.com/kb/314090
Internet synchronization won't work unless the system time is within a few minutes of the time that the server gives back. As Geek has stated the time is way off when he REQUIRES this feature which makes it sorta useless. It will right eventlog entries THOUGH. that's useful.download GNU date , and then setting time/date is easy set the time forward 2 minutes
Code: [Select]c:\test> gnu_date --set="+2 minutes"
set to APR 17 2010
Code: [Select]C:\test>gnu_date --set="20100417"
|