So I finished my project and now would like to create a trial version of the runtime that works full for 7 days and after that can't open any longer or is being locked in some way. How would I do this?
The simplest solution is to set up the OnfirstWindowOpen trigger to run a script that checks a global date field. If it's empty, set it to an expiration date calculated from Get ( CurrentDate ) + 7. If it's not empty compare the value of Get ( CurrentDate ) to the date in the field and quit after showing the user and expiration message.
Note that this can easily be "spoofed" by the user if they play games with their system clock.
More sophisticated approaches might get a date from a web site or might count the number of times that the solution is launched rather than just checking the date.
philmodjunk is right about this one. While I was trying to setup a Sample file, the only thing I couldn't figure out was how to stop them from muddling with the System clock. Never thought about the getting the time from online.
And don't forget that a user can just re-install to gain more time. That might not be a major problem as the new install won't have any user entered data from the first, but it's one more way to game the system.
Other options including putting large text on crucial layouts--particularly report layouts that read "TRIAL COPY" or some such to limit the real world usefulness of the trial copy. You can either use a separate installer for licensed copies of your solution or you can "unlock" your solution by either putting this text in a field so that a script can clear it or use a Hide Object When expression to hide the layout text when the file is properly unlocked with a license code.
Ultimately, your best anti-piracy measures will be a set up that accesses a web site that you control to confirm that the user is authorized to use a copy of your solution.
I was thinking of locking the fields or stop the runtime from launching all together when the amount of launches has been reached. Or indeed creating 2 different runtimes, one limited and one normal version so the user will have to download the normal version if he wants to use the runtime fully. Of course that would make easier to simply spread the program around after that, but that would also be possible when a user has an unlock code.
How can I let the amount of launches being counted? I searched for examples but cannot find anything.
It might be useful to make a list of ways that any such system could be broken, and then to be sure you have addressed those. Otherwise, you may instill a false sense of security. Locking the front and back doors is good; but what if all the windows are left open?
Steven H. Blackwell
Platinum Member Emeritus, FileMaker Business Alliance
Getting date from internet can work if the computer is connected to it; don't give as granted that it is.
Create a control table having
myUTC, autoenter Get(CurrentTimeUTCMilliseconds);
maxUTC, summary max(myUTC)
minUTC, summary min(UTC).
On every launch create a record in this table. (Go to it and) check If myUTC ≠ maxUTC => clock has been tampered with, so quit. If MyUTC > minUTC + 7 * 24 * 60 * 60 * 1000, expired so quit.
Also remember that besides the well-known triggers OnFirstWindowOpen etc, in File Options / Open you can specify a layout to switch to. And that specific layout can have its own "OnLayoutEnter" trigger, specified in Layout setup - script triggers, which can call a specific script.
I have everything working up till the point that with every launch of the database a new record is created. When a set amount of reached a new window will open with an (trial is over, please register now" layout. There is a "UnlockCode" text field on this layout where the user can enter the unlock code and 2 buttons; one to confirm the unlock code, and a cancel button that will exit the application.
I placed this calculation in the "UnlockCode" text field: GetField ( unlockCode ) to get the text that the user is entering in the field.
The button that confirms the unlock code (yes or not correct code is entered) runs this script when clicked:
Retrieving data ...