|
Answer» I want to run a batch file every three weeks to do some cleaning on my computer. with scheduler i can only CHOOSE between day, week, month and so on. but not three weeks
is there a possibility that i can check if when the last time is has the batch file has run and if this was three weeks ago
i wanted to do this by reading the date in the batch file save this date as a number, and then the next time read this number and compare it. if the number is under 21 days than the batch file shoul not run. otherwise it should run and assigne a new date to the number
has somebody a solution for this or another solution.
thanks
MarcThis should work.
It launches your "run update.bat" when the computer is started on or after the 3 week mark. It creates and maintains a file in the temp FOLDER.
CODE: [Select]echo off set "datetest=%temp%\datetest.txt" if not exist "%datetest%" call :get-date 21 call :get-date 0 set /p d=<"%datetest%" echo today is "%DATA%" and the target date is "%d%" if %data% GEQ %d% ( call "run update.bat" call :get-date 21 ) pause
goto :EOF :get-date (set day=%~1) echo >"%temp%\%~n0.vbs" s=DateAdd("d",%day%,now) : d=weekday(s) echo>>"%temp%\%~n0.vbs" WScript.Echo year(s)^& right(100+month(s),2)^& right(100+day(s),2) for /f %%a in ('cscript /nologo "%temp%\%~n0.vbs"') do set "result=%%a" del "%temp%\%~n0.vbs" set "YYYY=%result:~0,4%" set "MM=%result:~4,2%" set "DD=%result:~6,2%" set "data=%yyyy%-%mm%-%dd%" if "%~1"=="21" >"%datetest%" echo %data% the computer will not start every dayThe modifed code above should still work for you.hi foxidrive
that works indeed
thanks for your help
regard
marc
|