AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Timer COMPLICATION
Goto page Previous  1, 2
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Laszlo



Joined: 14 Feb 2005
Posts: 4078
Location: Pittsburgh

PostPosted: Sun May 01, 2005 3:33 pm    Post subject: Reply with quote

I’ve found a workaround. Write the correct date and time in a batch file and run the batch file instead of the command processor.
Code:
#persistent
Tick0 = %A_TickCount%
Time0 = %A_Now%

SetTimer TimeCheck, 1000
return

TimeCheck:
   Transform SecTick, Round, (A_TickCount-Tick0)/1000
   SecPC = %A_Now%
   SecPC-= Time0,S      ; Time Difference in Seconds

   if (SecTick-SecPC < 2 && SecPC-SecTick < 2)
      Return

   Time0 += SecTick,S   ; Keep time as YYYYMMDDHH24MISS
   FormatTime Date, %Time0%, MM-dd-yyyy
   FormatTime Time, %Time0%, HH:mm:ss

   FileDelete ResetDateAndTime.bat
   FileAppend Date %Date%`nTime %Time%, ResetDateAndTime.bat
   runwait ResetDateAndTime.bat

   Tick0 = %A_TickCount%
   Time0 = %A_Now%

   MsgBox PC time has been changed!`nWe have just reset it for you.
Return
Back to top
View user's profile Send private message
garry



Joined: 19 Apr 2005
Posts: 1186
Location: switzerland

PostPosted: Mon May 02, 2005 6:06 am    Post subject: Reply with quote

have XP, this works:
Code:
run %COMSPEC% /K time 14:00:10
Back to top
View user's profile Send private message
Laszlo



Joined: 14 Feb 2005
Posts: 4078
Location: Pittsburgh

PostPosted: Mon May 02, 2005 3:11 pm    Post subject: Reply with quote

Cool! It works. The key is to use cmd.exe (%COMSPEC%), not command.com. Who knew they are so different? Actually, the /C has to be used:
Code:
run %COMSPEC% /C time 11:00:00
otherwise a command window is left open.
Back to top
View user's profile Send private message
Laszlo



Joined: 14 Feb 2005
Posts: 4078
Location: Pittsburgh

PostPosted: Mon May 02, 2005 3:27 pm    Post subject: Reply with quote

So, with Garry’s help the time-change-prevention script is further simplified:
Code:
#persistent
Tick0 = %A_TickCount%
Time0 = %A_Now%

SetTimer TimeCheck, 1000
return

TimeCheck:
   Transform SecTick, Round, (A_TickCount-Tick0)/1000
   SecPC = %A_Now%
   SecPC-= Time0,S      ; Time Difference in Seconds

   if (SecTick-SecPC < 2 && SecPC-SecTick < 2)
      Return

   Time0 += SecTick,S   ; Keep time as YYYYMMDDHH24MISS
   FormatTime Date, %Time0%, MM-dd-yyyy
   FormatTime Time, %Time0%, HH:mm:ss

   runwait %COMSPEC% /C Date %Date%
   runwait %COMSPEC% /C Time %Time%

   Tick0 = %A_TickCount%
   Time0 = %A_Now%

   MsgBox PC time has been changed!`nWe have just reset it for you.
Return
To defeat it the user has to delete cmd.exe from the Windows directory. It is a system file, so Windows (2K, XP) replaces it immediately. There is a trick to remove it anyway: in a batch file delete it and rename another system file to cmd.exe, but it will cripple Windows. But in any case, temper resistant SW has to periodically check if there is a valid cmd.exe, and restore it if needed.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group