Store epoch in ChangesAvailableSince

To compute a correct date if updates are available less than 7 days before the end of the month
master
Daniel Berteaud 9 years ago
parent 046d4b8d9d
commit 5b8f4c7c40
  1. 6
      softwares/FWSUpdates/bin/chkupd.bat
  2. 1
      softwares/FWSUpdates/bin/now.vbs
  3. 4
      softwares/FWSUpdates/bin/sync.bat

@ -68,7 +68,7 @@ IF %CHANGES% LSS 1 IF %ADMIN% NEQ 1 (
goto :EOF goto :EOF
) )
SET /A NOW=%DATE:~-4%%DATE:~3,2%%DATE:~0,2% FOR /F "delims=" %%A in ('cscript /nologo %~dp0\now.vbs') DO SET /A NOW=%%A
SET /A SINCE=%NOW% SET /A SINCE=%NOW%
reg query "HKLM\Software\FWS\Updates" /v ChangesAvailableSince 1>NUL 2>NUL reg query "HKLM\Software\FWS\Updates" /v ChangesAvailableSince 1>NUL 2>NUL
IF %ERRORLEVEL% EQU 0 FOR /F "tokens=3 delims= " %%A IN ('reg query "HKLM\Software\FWS\Updates" /v ChangesAvailableSince') DO SET /A SINCE=%%A IF %ERRORLEVEL% EQU 0 FOR /F "tokens=3 delims= " %%A IN ('reg query "HKLM\Software\FWS\Updates" /v ChangesAvailableSince') DO SET /A SINCE=%%A
@ -83,9 +83,11 @@ IF %CHANGES% EQU 1 (
) )
REM Compute how many days left we can delay updates REM Compute how many days left we can delay updates
SET /A MAX=%SINCE%+%MAX_REPORT% SET /A MAX=%SINCE%+%MAX_REPORT%*86400
SET /A AGE=%NOW%-%SINCE% SET /A AGE=%NOW%-%SINCE%
SET /A AGE=%AGE%/86400
SET /A REMAINING=%MAX%-%NOW% SET /A REMAINING=%MAX%-%NOW%
SET /A REMAINING=%REMAINING%/86400
REM Non admin on RDP shouldn't see updates notif REM Non admin on RDP shouldn't see updates notif
IF %ADMIN% NEQ 1 IF NOT "%SESSIONNAME%" == "Console" goto :EOF IF %ADMIN% NEQ 1 IF NOT "%SESSIONNAME%" == "Console" goto :EOF

@ -0,0 +1 @@
WScript.Echo DateDiff("s", "01/01/1970 00:00:00", Now())

@ -151,7 +151,7 @@ FOR /F "tokens=2 delims= " %%A IN ('cscript %SystemDrive%\FWSUpdates\repository\
SET /A CHANGES=!CHANGES!+1 SET /A CHANGES=!CHANGES!+1
) )
echo %DATE% %TIME% - Found %CHANGES% changes >> %SystemDrive%\FWSUpdates\status\sync_log.txt echo %DATE% %TIME% - Found %CHANGES% changes >> %SystemDrive%\FWSUpdates\status\sync_log.txt
SET NOW=%DATE:~-4%%DATE:~3,2%%DATE:~0,2% FOR /F "delims=" %%A in ('cscript /nologo %~dp0\now.vbs') DO SET /A NOW=%%A
reg add "HKLM\Software\FWS\Updates" /v PendingChanges /t REG_DWORD /d %CHANGES% /f reg add "HKLM\Software\FWS\Updates" /v PendingChanges /t REG_DWORD /d %CHANGES% /f
reg add "HKLM\Software\FWS\Updates" /v PendingChangesList /t REG_SZ /d "%LIST%" /f reg add "HKLM\Software\FWS\Updates" /v PendingChangesList /t REG_SZ /d "%LIST%" /f
@ -161,7 +161,7 @@ IF %CHANGES% GTR 0 (
IF ERRORLEVEL 1 ( IF ERRORLEVEL 1 (
reg add "HKLM\Software\FWS\Updates" /v ChangesAvailableSince /t REG_DWORD /d %NOW% /f reg add "HKLM\Software\FWS\Updates" /v ChangesAvailableSince /t REG_DWORD /d %NOW% /f
SET /A SINCE=%NOW% SET /A SINCE=%NOW%
SET /A MAX=%SINCE%+%MAX_REPORT% SET /A MAX=%SINCE%+%MAX_REPORT%*86400
) ELSE ( ) ELSE (
FOR /F %%A IN ('reg query "HKLM\Software\FWS\Updates" /v ChangesAvailableSince') DO SET /A SINCE=%%A FOR /F %%A IN ('reg query "HKLM\Software\FWS\Updates" /v ChangesAvailableSince') DO SET /A SINCE=%%A
SET /A MAX=%SINCE%+%MAX_REPORT% SET /A MAX=%SINCE%+%MAX_REPORT%

Loading…
Cancel
Save