Code for detecting when a free trial has expired.

Started by pguild, April 20, 2023, 03:38:03 PM

Previous topic - Next topic

pguild

i have an awesome program that I want to distribute. I would like to give people, say, a 7-day free trial.

Any tips on how to code the program so that it will detect when the free trial is over and invite them to buy the program?

Upon expiration, the user would be sent to a web page where they can click a PayPal button. PayPal, I hope, could then redirect the user to another hidden page where an unlock code would be revealed.

www.DogTrainingPsychology.com -- "Don't wish it were easier, wish you were better."  as aphorism by Jim Rohn as quoted in the Kindle Book, GEMS OF WISDOM by Philip Seyer

ChuckC

Unless you use some unique piece of information from the computer that your software was installed on and send it out to some place on the 'Net to store it with along with the start date for the evaluation, there is *absolutely* *nothing* that you can do that will stop a determined person from bypassing your evaluation time limit.  Period.  End of discussion.  No "buts".

Understand, there is one sole single place that you can persist some information across reboots and installation/uninstallations of your application, and that's in the file system on a mounted volume.  Many people would consider the registry as a second choice, but the registry itself is nominally a specialized type of file system stored in registry "hive" files in, you guessed it, the file system.  Anything stored locally can be found in the file system can be found can be modified or deleted if you have sufficient privileges and/or permissions.  So, nothing stored locally on the computer can be used in an absolutely secure manner to persist your installation date & time stamp to enforce an evaluation time limit.

With that said, the typical thing that is done is to examine the modified date of a file that was placed on the computer as part of your installation process; the creation date won't typically change during the installation process, but the modified date will definitely change.  Another thing that is done is to write a registry value containing the installation date & time stamp.  Deleting your app's files by uninstalling it and and re-installing it will defeat this methodology.

If you want to get just a little bit devious, lay down a "ReadMe.txt" file and then save the installation date & time stamp in a "named stream" on that file.  If you don't know what a "named stream" is on a NTFS volume, Google is your friend, as is the tech support database of KB articles here in WinBatch world.  However, deleting the file and re-installing your software will defeat this methodology.

Yet another thing that is commonly done is to write a value in the registry for your software that records the installation date.  Savvy users are up-to-speed on this methodology and will easily defeat it.

As for the initial suggestion, obtain the BIOS UUID value for the computer.  It is unique on a per-motherboard basis, although virtual machines can wreak a little havoc with duplicates or randomly generated values every time the VM is "power cycled".  Then, send that BIOS UUID value to some central location on the 'Net and record the date & time stamp when you receive it.  Since the pairing of "installation time" and "unique ID of the computer" are not stored on the computer, there's no way for anybody to bypass it short of doing some binary hacking of your application.  WinBatch makes that an unpleasant & non-trivial task for a compiled script, but it's not impossible if somebody really really really really really really wants to break your evaluation time limit.


JTaylor

You could also go with a hashed license key in which the date is part of the data.   Again, as noted, not foolproof but everything is self-contained.   The downside is you might lose some people due to not wanting to register enough info to be sent a key.

Jim

jmburton2001

Many years ago I wrote a script to do just that...

It's in the Tech Database -> Script Expire Routine

It can be easily modified to do what you want!  8)

pguild




Quote from: ChuckC on April 20, 2023, 06:25:46 PM
Unless you use some unique piece of information from the computer that your software was installed on and send it out to some place on the 'Net to store it with along with the start date for the evaluation, there is *absolutely* *nothing* that you can do that will stop a determined person from bypassing your evaluation time limit.  Period.  End of discussion.  No "buts".

Thanks, ChuckC, I don't expect to create a totally foolproof system. If someone can figure out how to bypass the time limit, that is fine. But most people using the software are not that technical and won't mind paying a few bucks to get an unlock code.
www.DogTrainingPsychology.com -- "Don't wish it were easier, wish you were better."  as aphorism by Jim Rohn as quoted in the Kindle Book, GEMS OF WISDOM by Philip Seyer

stanl

If you feel the users wouldn't be interested in trying to hack... you might get away with creating a .sys file somewhere on initial load of your application then just play off that files time. Code below is set to 7 days but easily tested by setting it to 1 ninute
Code (WINBATCH) Select


data = ""
file =  "C:\temp\test.sys" ;or any location you want


If Fileexist(file)
   fTime = FileYmdHms(file)
   expires = TimeAdd(fTime,"0000:00:07:00:00:00")
   now = TimeYmdHms()
   If now > expires
       Message("Warning","your time is up")
   Else
       Message("Warning","Expires ":expires)
   Endif
Else
   Fileput(file,data)
Endif

pguild

Thanks, stani.  Why would you create a sys file as opposed to some other file type?
www.DogTrainingPsychology.com -- "Don't wish it were easier, wish you were better."  as aphorism by Jim Rohn as quoted in the Kindle Book, GEMS OF WISDOM by Philip Seyer

stanl

Quote from: pguild on April 24, 2023, 02:13:06 PM
Thanks, stani.  Why would you create a sys file as opposed to some other file type?


I would use that extension. Not really a system file, but average user probably would try to open it an therefore change the file date.

jmburton2001