@ECHO OFF
REM [url=http://www.tomshardware.fr/forum/id-2964148/parametrer-acces-logiciel.html]http://www.tomshardware.fr/forum/id-2964148/parametrer-acces-logiciel.html[/url]
SET /a TOP=%TIME:~0,2%*60+%TIME:~3,2% >NUL
REM %TOP% contient l'heure courante en minutes.
REM Vérifions une plage de disponibilité :
REM 8h30 / 17h00 -> 510 min. / 1020 min.
IF %TOP% GEQ 1020 (
ECHO Il est trop tôt. Attendez 8h30.
PAUSE
EXIT 1
)
IF %TOP% LSS 510 (
ECHO Il est trop tard !
PAUSE
EXIT 1
)
REM Lecture du fichier avec TYPE et récupération de la valeur avec FOR /F
FOR /F %%I IN ('TYPE fichier_acces') DO IF %TOP% LSS %%I (
ECHO Il est trop tôt. Veuillez patienter...
PAUSE
EXIT 1
)
REM C'est bon. On peut y aller !
REM On met un GROS nombre, pour interdire l'accès :
ECHO 9999 > fichier_acces
REM On exécute le programme :
programme
REM Quand le programme rend la main, l'heure du prochain accès autorité est enregistrée dans le fichier
REM J'ai ajouté 60 minutes. On peut imaginer autre chose.
SET /a TOP=%TIME:~0,2%*60+%TIME:~3,2%+60 >NUL