Account Expiration Calculation during logon.
Simply insert this entire script into your logon.bat file, or save it as it's own script and call it from your logon.bat script.
| @echo off REM **************************************************************************************************************** REM * REM * Batch file created by Rod Harrison on 7/7/2003 REM * Written to work in a Windows 2000 AD environment REM * - First Line determines the actual date the user account will expire, if it is set to expire, and places REM * that date into a parameter called %dte% REM * - Second Line determines if the account's expiration is set to NEVER, or will not expire, then skips to REM * NOEXP (Do not run this code) REM * SECTION "CALC" determines the difference between "TODAY" and the account expiration date and sets the result REM * to %d1%. Then if %d1% is less than 31 then display a message to the user logging on. REM * - If the difference between "TODAY" and the expiration date is greater then 30 no message is displayed! REM * REM **************************************************************************************************************** REM * leave the following 2 lines as written, do not change anything (Even /domain) for /f "Skip=8 Tokens=1-3" %%a in ('net user "%username%" /domain') do if /i "%%a"=="Account" if /i "%%b"=="expires" set dte=%%c If /i "%dte%"=="Never" goto :NOEXP REM ****************** REM * SECTION "CALC" * REM ****************** REM * Change %SERVER% to the name of the server where your netlogon share is located for /f "Tokens=1" %%a in ('\\%SERVER%\netlogon\fdate\fdate.exe /Fdif /B%dte%') do set d1=%%a if %d1% LEQ 30 goto write GOTO NOEXP :WRITE echo >c:\$temp1.txt Your system account will expire on %dte%. Contact the Helpdesk at extension 6262 for assistance. \\%server%\netlogon\bulletin c:\$temp1.txt REM ******************************************************************************** REM * Deleting the temporarily created file used to display the Expiration Message * REM ******************************************************************************** del c:\$temp1.txt :NOEXP |