批处理以调整任务计划程序运行的夏令时更改

时间:2018-03-29 21:38:41

标签: batch-file

我需要在PC上更改时间以调整任务调度程序运行的夏令时更改,因此,我制作了这个小批处理文件,我需要知道该代码是否正确,因为我觉得有些内容正确无误该 当我将它与打印时间ECHO Current Time is %TIME%

的第一行进行比较时,最终结果的毫秒部分是不正常的

备注

  1. 我无法使用Pwoershell
  2. 它应与windows 7XPwindows server 2003
  3. 一起使用

    提前感谢您的帮助

    @ECHO OFF
    TITLE Daylight Saving
    
    SET CurrentHours=%TIME:~0,2%
    
    ECHO.
    ECHO Current Time is %TIME%
    
    REM ECHO %TIME:~0,2% REM --- Hours
    REM ECHO %TIME:~3,2% REM --- Minutes
    REM ECHO %TIME:~6,2% REM --- Seconds
    REM ECHO %TIME:~9,3% REM --- Milliseconds
    
    
    if %CurrentHours% LSS 23 SET /a CurrentHours=%CurrentHours%+1
    if %CurrentHours% EQU 23 SET CurrentHours=00
    
    TIME %CurrentHours%:%TIME:~3,2%:%TIME:~6,2%.%TIME:~9,3%
    
    ECHO.
    ECHO Time has been adjusted for Daylight saving changes.Current time now is %TIME%
    
    
    PAUSE
    REM --- EXIT
    

1 个答案:

答案 0 :(得分:0)

Windows具有以下功能:“禁用Windows时钟到DST的自动更新设置。”然后你不必在凌晨2点起床手动完成。这个网页教程详细解释了它。

http://in5stepstutorials.com/windows-7/prevent-automatically-changing-windows-time-to-dst.php