Skip to main content
Participating Frequently
August 25, 2017
Question

Can you set a file to "self destruct" after a set period of time?

  • August 25, 2017
  • 2 replies
  • 3881 views

Hi!

I have someone interested in using a script that I had made. I would like to let them use it but I want to have some control over the period of time they are able to. My plan is to encrypt the script and hopefully set it to self destruct after a year, so they need a new file from me to continue using it. This way, if we stop doing business they can no longer use the script.

Is there a simple way to do something like this?

Thanks!

This topic has been closed for replies.

2 replies

Participating Frequently
August 30, 2017

I was able to get both of those to give the dialogue box but I was unable to get it to actually exit the script. I am not sure what I would put in to have it exit the script if expired.

Silly-V
Legend
August 30, 2017

It's in how you write the script: you've got to put the snippet in somewhere in the beginning of the script you have, and have that return statement exit the script and do nothing else. You'll notice my snippet is inside a function, so you may want to take the innards of it and paste it as the first lines of your existing script. Use just this part:

  // year = 2018, months = 11 (0-11), date = 31 (1-31), hours = 23 (0-23), minutes = 59 (0-59)

  var expirationDate = new Date(2018, 11, 31, 23, 59);

  var today = new Date();

  if(today.getTime() > expirationDate.getTime()){

    alert("Please contact me to get a new version of this script.");

    return;

  } else {

    alert("Your script is still valid.");

  }

Silly-V
Legend
August 25, 2017

In the script, you can easily put in a statement to exit the script based on a javascript Date.

Check this snippet out: it has an expiration date of Dec 31, 2018 at 11:59pm.

#target illustrator

function test(){

  // year = 2018, months = 11 (0-11), date = 31 (1-31), hours = 23 (0-23), minutes = 59 (0-59)

  var expirationDate = new Date(2018, 11, 31, 23, 59);

  var today = new Date();

  if(today.getTime() > expirationDate.getTime()){

    alert("Please contact me to get a new version of this script.");

    return;

  } else {

    alert("Your script is still valid.");

  }

};

test();

Then, out of your ExtendScript Toolkit, you can export the jsx script file as .jsxbin, which is a binary format that a human can't read or edit!

Participating Frequently
August 25, 2017

Thanks Silly! That seems like it will work perfectly. I will give it a try asap.

Tomas Sinkunas
Legend
August 26, 2017

Some time ago I wrote this snippet AE Script: Expired — Bitbucket ​and I always include it into my scripts I sent to client, until the payment comes through. It's a safe way to ensure that your script will not be useable after some given time.

Check it out.