Making a standalone that will only run a few times ?

Augustine Bannatyne - Leudar's icon

Is there a way of making a standalone (exe) that will basically stop working after it sbeen opened a few times. Is there a way of the max patch recording how many times its been opened and then rewriting some element that would stop it working again ? I guess like demo software....

Jean-Francois Charles's icon

[loadbang] and [counter] could help. Someone knowing Max could overcome any such scheme, of course.

Augustine Bannatyne - Leudar's icon

will the count be saved though for when you close and open the exe again... or will it just go back to zero - it needs to autosave the new count somehow....

Jean-Francois Charles's icon

You're right: you'd need to write the number in a file on disk. Security with modern OS will allow you to write only in certain places, but not in the Application package itself: you'd write this number in a file stored in a Preferences folder I guess.

Christopher Dobrian's icon

The pattr object is useful in this regard. You can store the count in it, and it's embedded within the file itself. If you copy and paste this example code into your patch and save it, you will then only be able to open the patch 5 times.

Max Patch
Copy patch and select New From Clipboard in Max.

Of course, a knowledgable person can hold down shift-command to defeat loadbang, or can open the patch as text and edit it, but it will effectively frustrate most non-expert users. To reset it, you'll need to do one of those things, then put 0 in the pattr and save.

Roman Thilenius's icon

storing the evaluation timeout in a textfile is about as safe as usi8ng a dialog warning the user that his evaluation period is over.

Augustine Bannatyne - Leudar's icon

Have you got any other suggestions Roman ?

Augustine Bannatyne - Leudar's icon

Thanks Christopher - a knowledgable person can get into any software - like you say I guess its just about making things inconvenient. TBH I pity the poor sod that breaks into one of my max patches - I hardly know whats going on in them myself - seeings as they'often eveolved out or previous patches....

Augustine Bannatyne - Leudar's icon

Hmm Christopher this doesnt seem to work for exe or mxf standalones, at least not on windows....

Christopher Dobrian's icon

Yeah, it occurs to me that, since it relies on re-saving the patcher, it probably isn't so suitable for standalone apps. So saving the count in a file (possibly encrypted in some simple way, if you want to go to the trouble), and then reading it back in when the patch is opened is probably the way to go.

Augustine Bannatyne - Leudar's icon

How would I do that ?

Christopher Dobrian's icon

Same idea as in the previous example, except the count is stored in a separate file. Note my oh-so-sophisticated encryption/decryption scheme: simply offsetting the count by the magic number 74. That number is stored in a .jxf file, read in when the patch is loaded, has 74 subtracted to it, has 1 added to it, has 74 added to it, and gets stored in the same file.

countkeeper.zip
application/zip 1.89 KB

Augustine Bannatyne - Leudar's icon

Hi Christopher thanks again - but as an exe it doesnt seem to write to the jxf - just says the same number everytime I open the exe....

Christopher Dobrian's icon

It works for me as a .app file for Macintosh if I don't include the .jxf file as part of the application but just keep it in the same folder as the application. Sorry, I can't test that on a Windows machine.