How to obtain the first installation date?

Hi everyone,
I want create a mechanism that will spot the first installation date of my plug in so that it will be able to count the days and after the end of trial period it will mute the plug in or luck it. I know there are some other options to handle do this (like online activation) but I need a quick method for now. I thought I could create a file that keeps the the current date when plug in is started and if there is a previous file or date then it won’t overwrite it again. So once the plugin is installed and that first file is created it will be the first installation date. Then I can get the current date and compare them. But with this plan if the user deletes that file than my plug in create a new and it will update the date :smiley: so is there a way that I can keep that date in somewhere that user cannot delete and I can pull and push easily?

1 Like

You could do marginally better if you create that file as part of the installation process, because the installer can run with administrator privileges and therefore put the file somewhere where the user will at least be warned before deleting.
But how to do so is outside the scope of JUCE because it depends on the installation mechanism. I am aware that using Packages on macOS and Inno Setup on Windows, it is possible to customize the installation process in such a way, although it might not be trivial, especially in Inno Setup where the scripting is in Pascal

Thank you for answer. I will try to handle it on the installer side but as you mentioned i dont know how i can put a mechanism that will take the date and put it in a folder that user cannot access by checking the previous situation.

There is nothing you can do, that the user cannot undo. You need an external information, that the user cannot recreate.
One way is an email bot, that sends out test licenses, where the server time is encoded, and keeps the email addresses of people who used it already. Obviously the user can repeat with throw away emails, but for a low priced plugin that might be already enough to nag the user into buying…

I suggest you first calculate an encrypted MD5 hashcode (MD5 encryption algorythm is quick to calculate) based on the installation date + a secret word that only your app knows and store the result into a file.
Each time you run the app (plug-in), you read the file and compare the MD5 hashcode from the file to the list of all the MD5 hashcodes corresponding to the authorized dates.

Installation date = 05/02/2020
secret word = mysecret
MD5 of 05/02/2020mysecret = a54f197cd0e76b06ae1440fb479c9059

Suppose the app is allowed 10 days (05/02/2020 to 14/02/2020):
The user runs the app on 10/02/2020 meaning you compare hashcodes from 01/02/2020 to 10/02/2020 -> ok the hashcode in the file is found -> access granted
The user runs the app on 19/02/2020 meaning you compare hashcodes from 10/02/2020 to 19/02/2020 -> NOK the hascode in the file is NOT found -> access NOT granted
Good Luck!

Luck is needed with that approach indeed.
As a user I simply watch the host which files it accesses when I start your plugin and tadaa.
I delete the file restart the host, a fresh demo starts.

yeah :slight_smile: this is what will happen (edit: this is what will happen with my plan)

Thank you very much for this detailed explanation :pray:

1 Like

No no no, @daniel if the file does not exist the app cannot start !!! It is the basic

1 Like

So where does a legitimate user get the file from?

@daniel / @mesut - best way is to provide the file (hashcode) and the app together. just you need to run a batch process which generates a new file on a daily basis. you can even pack the executable and the hashcode file in a zip file or whatever archive format to make it easier to install

although that doesn’t stop me to uninstall and redownload…

But I just had an idea, you could save the hash in each session, so an unregistered session would not load after a week. I think that would be annoying enough to buy a license.

yep, session or IP address or both

Simpler than that: when creating the instance, put the date in the state, that is saved alongside the plugin state via setStateInformation.
In getStateInformation, if the date is older than say a week and no license is found, just don’t load the settings.

It doesn’t give you the first installation, but it’s something that expires and nags the user into buying


good idea. and yes there will always be hackers to crack the thing indeed. So the idea is to find a solution that prevents the usual user to do it

That’s what I was headed for:
There cannot be a safe system if it is computed on the user’s system in isolation. Worst case the user can set back the clock of his system.
But a system that throws obstacles towards an unregistered user, so if they finally buy if they are willing to. There is no point for an arms race with the hackers, you won’t have time to develop a product in the end.
(You can of course buy solutions for that, just mentioning and many other :wink: )

1 Like

@mesut have you read this tuto yet This might help?

Sorry i couldn’t check replies for a while. Thank you very much for your answer. I checked it . Looks like the best way is online status checking.

Except for people who don’t have their studio computers on the internet.

1 Like

yes :smiley: this is another good point.