 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Laszlo
Joined: 14 Feb 2005 Posts: 4078 Location: Pittsburgh
|
Posted: Sun May 01, 2005 3:33 pm Post subject: |
|
|
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 |
|
 |
garry
Joined: 19 Apr 2005 Posts: 1186 Location: switzerland
|
Posted: Mon May 02, 2005 6:06 am Post subject: |
|
|
have XP, this works: | Code: | | run %COMSPEC% /K time 14:00:10 |
|
|
| Back to top |
|
 |
Laszlo
Joined: 14 Feb 2005 Posts: 4078 Location: Pittsburgh
|
Posted: Mon May 02, 2005 3:11 pm Post subject: |
|
|
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 |
|
 |
Laszlo
Joined: 14 Feb 2005 Posts: 4078 Location: Pittsburgh
|
Posted: Mon May 02, 2005 3:27 pm Post subject: |
|
|
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 |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|