I have a problem with a date check within a batch file.
I have a file under "C:\Windows" called "apsch" where i enter a date until nothing should happen. But when the date has passed i want the batch file to rename another file.
My Problem is that it only looks for the day, but ignores the month and year.
What is working:
When the "validthru-date" is further than 9 days the batch file closes immediately
When the "validthru-date" is within the next 9 days a message appears
What is not working:
eg: Today is the 22nd of Jan.
When i enter the 21st of Feb. (validthru=21.02.2020) it says that this day has already passed.
Hope anyone can help me!
Thanks
Jürgen
"apsch" (from C:\Windows)
Code: Select all
validthru=20.01.2020
Code: Select all
@echo off
mode con:cols=100 lines=1
title Heute ist der %date%
cls
if not exist "C:\Windows\apsch" goto valid
for /f "tokens=1,2 delims==" %%a in (C:\Windows\apsch) do (if %%a==validthru set validthru=%%b)
if %validthru% lss %date% (goto invalid) else (goto valid)
:invalid
cls
cd\
cd aprokassa
cd Executeables
ren borlndmm.dll locked
taskkill /IM apro_bon.exe
cls
ping 127.0.0.1 -n 2
cls
::start apro_bon.exe
color 0c
mode con:cols=90 lines=11
title Heute ist der %date%
cls
echo;
echo;
echo **********************************************************************************
echo;
echo Ihre Lizenz ist am %validthru% abgelaufen.
echo Bitte wenden Sie sich an unseren Support!
echo;
echo **********************************************************************************
echo;
cmd /k @echo off
:valid
cls
cd\
cd aprokassa
cd Executeables
ren locked borlndmm.dll
cls
tasklist /FI "IMAGENAME eq apro_bon.exe" 2>NUL | find /I /N "apro_bon.exe">NUL
if "%ERRORLEVEL%"=="0" (echo Program is running) else (start C:\aprokassa\Executeables\apro_bon.exe)
cls
echo WScript.Echo DateAdd("d", 9, Now) > "C:\aprosystem\days.vbs"
for /f %%a in ('cscript //nologo "C:\aprosystem\days.vbs"') do set NewDate=%%a
::echo %NewDate%
if %validthru% lss %NewDate% (goto message) else (goto end)
:message
cls
color 0a
mode con:cols=90 lines=11
title Heute ist der %date%
cls
echo;
echo;
echo **********************************************************************************
echo;
echo Ihre Lizenz ist gueltig bis %validthru%
echo Bitte wenden Sie sich, fuer eine Verlaengerung, an unseren Support!
echo;
echo **********************************************************************************
echo;
cmd /k @echo off
:end
exit