-2

我正在做一个自动更新系统,如果软件在一定天数内没有更新,我需要系统打开一个网页。我记录了每次自动更新的日期,所以我需要帮助的是获取上次自动更新和当前日期之间的天数。我希望您也可以提供有关您的代码的解释,非常感谢您的努力,在此先感谢。

4

3 回答 3

4

这是使用VBS的解决方案

@echo off
set "from=01-01-2001"
set "to=12-19-2011"
echo Wscript.Echo #%to%# - #%from%# >tmp.vbs
for /f %%a in ('cscript /nologo tmp.vbs') do set "total=%%a"
del tmp.vbs
echo The Total number of days from %from% until %to% is %total%
于 2013-10-03T13:21:22.030 回答
0

You may also want to try something like this.

    set/p searchdate= Enter search date (ddmmyyyy):  
于 2013-10-03T13:12:20.870 回答
0

我把这个松鼠了:

:: Using Powershell
:: Count the number of days from %1 to %2 
:: date format is yyyy/mm/dd

@echo off
set from=2001/01/01
set to=2011/12/19
if not "%~1"=="" set from=%1
if not "%~2"=="" set to=%2
set /a a1=%from:~0,4% + 1
set /a a2=%to:~0,4% - 1
if %from:~0,4% EQU %to:~0,4% (
set "sameyear=(get-date %to%).dayofyear - "
) else (
set "sameyear=(get-date %from:~0,4%/12/31).dayofyear - " 
)

>file.ps1  echo Set-ExecutionPolicy unrestricted
>>file.ps1 echo $a=%sameyear%(get-date %from%).dayofyear

for /L %%a in (%a1%, 1, %a2%) do (
>>file.ps1 echo $a=$a + (get-date %%a/12/31^).dayofyear
)

if NOT %from:~0,4% EQU %to:~0,4% (
>>file.ps1 echo $a=$a + (get-date %to%^).dayofyear
)
>>file.ps1 echo.echo $a

for /f "delims=" %%a in (
'powershell -file file.ps1'
) do set total=%%a
del file.ps1 2>nul
echo The Total number of days from %from% until %to% is %total%
于 2013-10-03T13:17:40.063 回答