Jump to content

Adding an expiration date to script


Recommended Posts

I need my script to look at todays date. If it is equal or passes my expiry date and it should exit my script

Can anyone tell me how to make my script stop working after a critain date.

So far I have this, but it doesn't seem to work. I'm not sure if I'm even writing the code properly.

Your assistance would be greatly appricitated.

#Include <date.au3>

$ExpireDate = "012/31/2006"

If $ExpireDate = _NowDate() Then

;Message the script has expired

Quit

Else

;Message: The script has not past the expiry date.

Do these steps

EndIf

Link to comment
Share on other sites

  • Moderators

That's because you have the date as a string, and 012/31/2006 will never exist...

#include <date.au3>
$ExpirationDate = '6/18/2006'
If _NowDate() = $ExpirationDate Then MsgBox(64, 'Info:', "I'm sorry but your license has ended")

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Developers

That's because you have the date as a string, and 012/31/2006 will never exist...

#include <date.au3>
$ExpirationDate = '6/18/2006'
If _NowDate() = $ExpirationDate Then MsgBox(64, 'Info:', "I'm sorry but your license has ended")
This will only show the message today... what about tomorrow ?

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Moderators

This will only show the message today... what about tomorrow ?

:D

I was only going off his code without thinking of > ... if that's the case then seperating it into @Mon - @MDay - @Year seems a lot more feasible to me then _NowDate() and parsing that.

Edit:

The more I think about this, I would just put the current date of installation somewhere, and then use a variable with the amount of days I'm going to give, and _DateAdd() to todays date, and compare it that way.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Developers

I would use something like:

$ExpirationDate = 20060618
If $ExpirationDate <= Number(@YEAR & @MON & @MDAY) Then 
    MsgBox(64, 'Info:', "I'm sorry but your license has ended")
    Exit
EndIf

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Moderators

I would use something like:

$ExpirationDate = 20060618
If $ExpirationDate <= Number(@YEAR & @MON & @MDAY) Then 
    MsgBox(64, 'Info:', "I'm sorry but your license has ended")
    Exit
EndIf
What happens when the expiration date is up, they get to use it :D just kidding your using <= rather than >

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Developers

What happens when the expiration date is up, they get to use it :D just kidding your using <= rather than >

yea you are rigth.. it should be >=

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Ok,, Here is the thing... the 012/31/2006 was a type o.. I meant 12/31/2006..

But I really appriciate all your responses and the options you have given me, and I will try them ASAP.

Oh,, by the way,, yes,, it should be >=

Again.. Thank you all..

Link to comment
Share on other sites

  • Moderators

Nope.. it's <=..

I tried >= and it doesn't work..

Maybe for how you have your script set up, but if you look at the example that was given, it's >= that would make the statement true.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...