$User = ucase(@USERID)
$Location = "Z:\" + @WKSTA + "_" + @USERID + ".txt"
$A = 0
$B = 0
$MM
$DD
$YYYY
Shell '%comspec% /c net user ' + @USERID + ' /domain > ' + $Location
Sleep 10
If Open(1, $Location) = 0
$x = ReadLine(1)
While SubStr($x,1,15) <> "Account expires"
$x = ReadLine(1)
Loop
$A = 30
While $M <> "/"
$M = SubStr($X,$A,1)
If $M <> "/"
$A = $A + 1
$B = $B + 1
EndIf
Loop
If $B = 2
$MM = SubStr($X, $A-$B, $B)
Else
$MM = "0" + SubStr($X, $A-$B, $B)
EndIf
$A = $A + 1
$B = 0
While $D <> "/"
$D = SubStr($X,$A,1)
If $D <> "/"
$A = $A + 1
$B = $B + 1
EndIf
Loop
If $B = 2
$DD = SubStr($X, $A-$B, $B)
Else
$DD = "0" + SubStr($X, $A-$B, $B)
EndIf
$A = $A + 1
$B = 0
While $Y <> " "
$Y = SubStr($X,$A,1)
If $Y <> " "
$A = $A + 1
$B = $B + 1
EndIf
Loop
$YYYY = SubStr($X, $A-$B, $B)
$EXPIRE = $YYYY + "/" + $MM + "/" + $DD
$DAYS = DATECALC($EXPIRE, @DATE)
Cls
SetConsole("alwaysontop")
Select
Case $DAYS > 90
;White/Green
Color W+/G
Box (0, 0, 23, 79, " ")
Color G+/G
At (3,23) Small "Your account expiration date is:"
At (7,0) Big $EXPIRE
; At (17,18) Small "You have " + $DAYS + " days to complete the mandatory"
; At (18,23) Small "Information Assurance Training."
Sleep 3
Case $DAYS < 90 And $DAYS > 45
;White/Yellow
Color W+/Y+
Box (0, 0, 23, 79, " ")
Color N/Y+
At (3,23) Small "Your account expiration date is:"
At (7,0) Big $EXPIRE
At (17,18) Small "You have " + $DAYS + " days to complete the mandatory"
At (18,23) Small "Information Assurance Training."
Sleep 7
Case $DAYS < 45
;White/Red
Color W+/R+
Box (0, 0, 23, 79, " ")
Color R/R+
At (3,23) Small "Your account expiration date is:"
At (7,0) Big $EXPIRE
At (17,18) Small "You have " + $DAYS + " days to complete the mandatory"
At (18,23) Small "Information Assurance Training."
Sleep 15
EndSelect
Close(1)
Else
Beep
? "Expire.txt file not opened, error code: [" + @ERROR + "]"
Sleep 5
EndIf
Del $Location /c
Return ; Must be last line of file. Do not remove this line
;FUNCTION DateCalc()
;
;AUTHOR Jochen Polster (jochenDOTpolsterATgmxDOTnet)
; based on date algorithms by Peter Baum to be found here :
; http://www.capecod.net/~pbaum/date/date0.htm
;
;VERSION 1.12
;
;VERSION HISTORY 1.0 2001/12/10 Initial release
;
; 1.1 2004/02/18 Added support for single digit month/day input
; and optional single digit month/day date return
;
; 1.11 2004/02/20 Minor Variable handling fix
;
; 1.12 2005/03/31 Finally supports "NoVarsInStrings" and "Explicit" set to "ON" in
; all possible variations
;
;ACTION Calculates days between 2 dates or returns a date string calculated from
; a given date and a given amount of days ( Addition of positive or negative
; integer value )
;
;SYNTAX DateCalc( Date1, Date2|Modifier, [SingleDigit] )
;
;PARAMETERS Date1 (Required)
; - (Gregorian) Date string in Format : YYYY/M[M]/D[D]
;
; Date2|Modifier (Required)
; - either a second (Gregorian) date string (YYYY/M[M]/D[D]) to calculate days between
; or a positive/negative amount of days to calculate with
;
; SingleDigit (Optional)
; - if not zero date will be returned unpadded, eg. 2004/2/9
;
;REMARKS Date format must be KiX friendly : YYYY/M[M]/D[D] (2001/11/20)
; To calculate a date less than given assign a negative integer (ie. -45 )
;
;RETURNS Either a positive integer value of days between two given dates,
; or a (Gregorian) date string.
;
;DEPENDENCIES None !
;
;EXAMPLES
; break on
; call "[path]DateCalc.udf"
;
; "boot.ini last modified : " + DateCalc(@date,substr(getfiletime("c:\boot.ini"),1,10))
; + " days ago ..." ? ?
;
; $mod = 60
; "in/before $mod day(s) it was/will be " + DateCalc(@date,$mod) ? ?
;
; get $
Function DateCalc($date1, $DateOrMod, optional $SingleDigit)
Dim $_intDate1, $_intYear1, $_intMonth1, $_intDay1
Dim $_intDate2, $_intYear2, $_intMonth2, $_intDay2
$date1 = Split($date1,'/')
If Ubound($date1) <> 2
Exit 1
EndIf
$_intYear1 = Val($date1[0])
$_intMonth1 = Val($date1[1])
$_intDay1 = Val($date1[2])
If $_intMonth1 < 3
$_intMonth1 = $_intMonth1 + 12
$_intYear1 = $_intYear1 - 1
EndIf
$_intDate1 = $_intDay1 + ( 153 * $_intMonth1 - 457 ) / 5 + 365 * $_intYear1 +
$_intYear1 / 4 - $_intYear1 / 100 + $_intYear1 / 400 - 306
Select
Case VarType($DateOrMod) = 3
$_intDate2 = $_intDate1 + $DateOrMod
If InStr($_intDate2,'-') $_intDate2 = Val(SubStr($_intDate2,2,Len($_intDate2)-1)) EndIf
$_intYear2 = ( 100 * ( ( ( 100*($_intDate2+306)-25)/3652425)
- ( ((100*($_intDate2+306)-25)/3652425)/4)
) + (100*($_intDate2+306)-25)
) / 36525
$_intMonth2 = ( 5 * ( ( ( 100*($_intDate2+306)-25)/3652425)
- ( ((100*($_intDate2+306)-25)/3652425)/4)
+ ($_intDate2+306) - 365 * $_intYear2 - $_intYear2 / 4
) + 456
) / 153
$_intDay2 = ( ( ( 100*($_intDate2+306)-25)/3652425)
- ( ((100*($_intDate2+306)-25)/3652425)/4)
+ ($_intDate2+306) - 365 * $_intYear2 - $_intYear2 / 4
) - ( 153 * $_intMonth2 - 457
) / 5
If $_intMonth2 > 12 $_intYear2 = $_intYear2 + 1 $_intMonth2 = $_intMonth2 - 12 EndIf
If not $SingleDigit
If Len($_intYear2 ) < 4
$_ = Execute("for $i=1 to 4-len($$_intYear2) $$_intYear2 = '0' + $$_intYear2 next")
EndIf
$_intMonth2 = right("0" + $_intMonth2,2)
$_intDay2 = right("0" + $_intDay2,2)
EndIf
$DateCalc = '' + $_intYear2 + '/' + $_intMonth2 + '/' + $_intDay2
Case VarType($DateOrMod) = 8
$DateOrMod = Split($DateOrMod,'/')
If Ubound($DateOrMod) <> 2
Exit 1
EndIf
$_intYear2 = Val($DateOrMod[0])
$_intMonth2 = Val($DateOrMod[1])
$_intDay2 = Val($DateOrMod[2])
If $_intMonth2 < 3
$_intMonth2 = $_intMonth2 + 12
$_intYear2 = $_intYear2 - 1
EndIf
$_intDate2 = $_intDay2 + ( 153 * $_intMonth2 - 457 ) / 5 + 365 * $_intYear2 +
$_intYear2 / 4 - $_intYear2 / 100 + $_intYear2 / 400 - 306
$DateCalc = $_intDate1 - $_intDate2
;comment the next line if you wish to return negative results also !!!
If InStr($DateCalc,'-') $DateCalc = Val(SubStr($DateCalc,2,Len($DateCalc)-1)) EndIf
Case 1
Exit 1
EndSelect
EndFunction