21 Replies Latest reply on Jun 5, 2018 4:54 PM by Polycontrast

    Trial or Time limited versions




      Is there any (simple) way to create a time limited version of a compiled script file? For example 30 days or 10 uses etc?

      If there's nothing built in does anyone know of any 3rd party solutions?


      Thanks for your time.

        • 1. Re: Trial or Time limited versions
          Paul Riggott Level 6

          You could write the date out to a file and check this file each time the script is run.

          1 person found this helpful
          • 2. Re: Trial or Time limited versions
            GreenShoot2 Level 1

            Would not changing the system date get around this?

            • 3. Re: Trial or Time limited versions
              Muppet Mark Level 5

              I think others may use an internet look up with the socket object… for number of runs you would only need an integer so no problem in writing that to file… You didn't actually say which language or OS so do you mean ExtendScript and both? With AppleScript you would just store a script 'property' variable and check or change on each run… It would have been nice to find something like this in the ESTK too…

              1 person found this helpful
              • 4. Re: Trial or Time limited versions
                GreenShoot2 Level 1

                Thanks for the reply.

                I was looking at javascript for the cross-platform capability - I'm not an expert coder by any means so I was hoping someone knew of an 'off the shelf' solution like there is for exe files.

                • 5. Re: Trial or Time limited versions
                  Paul Riggott Level 6

                  Changing the system date would get around it but the user would have to change the system time to the time the trial started to the expiry time. Not many users would want to change the system time as it would impact on a multitude of things.

                  • 6. Re: Trial or Time limited versions

                    Just thinking aloud, i am too looking for a mean to create time limited usage on my scripts.


                    Is it possible to have a "file" which records either the amount of time, or the number of times the script has been used. The next question is, how do we avoid our potential "clients" from tampering with that particular file?



                    If the script open and cant find that particular file, it will not run.

                    Script open the file and read off how many times the file has been run.

                    If the maximum time has been reached, file closes.

                    If not, finish up the script and then add Count+1 into the file and close the file.



                    • 7. Re: Trial or Time limited versions
                      Paul Riggott Level 6

                      One possibility is to use the registry if on a windows system, you could create a key(s) to store information that could be retrieved on each run of the script.

                      Here is a basic example of a trial script set for 30 days (each day starts at 12 noon).



                      function main(){
                           alert("Sorry this is a Windows only script");
                      var maxTrialDays = 30;
                      var VBFile = File(Folder.temp + "/v.vbs");
                      var daySince1970 = File(Folder.temp + "/v.dat");
                      if(daySince1970.exists) daySince1970.remove();
                      if(VBFile.exists) VBFile.remove();
                      var VB =
                      'Option Explicit\r' +
                      'Dim Temp, Secs, timeStart, fso , tempfolder, dateFile\r' +
                      'On error resume next\r' +
                      'Set fso = CreateObject("Scripting.FileSystemObject")\r' +
                      'Const TemporaryFolder = 2\r' +
                      'Set tempfolder = fso.GetSpecialFolder(TemporaryFolder)\r'+
                      'Set dateFile = fso.CreateTextFile(tempfolder  & "\\\\v.dat")\r' +
                      'timeStart = "1/1/1970 12:00:00 AM"\r' + 
                      'Secs = Cint(datediff("s", timeStart, now())/86400)\r' +
                      'Temp = ReadReg("HKCU\\SOFTWARE\\Trial\\MyScript")\r' +
                      'If Err.Number <> 0 then\r' +
                      'Err.Clear\r' +
                      'Temp = WriteReg("HKCU\\SOFTWARE\\Trial\\MyScript",Secs,"REG_DWORD")\r' +
                      'Temp = ReadReg("HKCU\\SOFTWARE\\Trial\\MyScript")\r' +
                      'dateFile.Write(Temp)\r' +
                      'dateFile.Close\r' +
                      'else\r' +
                      'Err.Clear\r' +
                      'dateFile.WriteLine(Temp)\r' +
                      'dateFile.Close\r' +
                      'end if\r' +
                      'fso.DeleteFile tempfolder  & "\\\\v.vbs", True\r' +
                      'Function WriteReg(RegPath, Value, RegType)\r' +
                      'Dim objRegistry, Key\r' +
                      'Set objRegistry = CreateObject("Wscript.shell")\r' +
                      'Key = objRegistry.RegWrite(RegPath, Value, RegType)\r' +
                      'WriteReg = Key\r' +
                      'End Function\r' +
                      'Function ReadReg(RegPath)\r' +
                      'Dim objRegistry, Key\r' +
                      'Set objRegistry = CreateObject("Wscript.shell")\r' +
                      'Key = objRegistry.RegRead(RegPath)\r' +
                      'ReadReg = Key\r' +
                      'End Function\r'
                      var dayNow = (Math.round(new Date().getTime()/1000/86400));
                      var originalDay = Number(daySince1970.read());
                      if(dayNow < originalDay) {
                          alert("Someone has reset the time!");
                      var daysUsed = (dayNow + 1 ) - originalDay;
                      if(daysUsed > maxTrialDays){
                          alert("Your trial period has expired\rThank you for trying this script\rwww.mysite.co.uk");
                      alert("This is the trial code\rLucky you\rYou have "+ (maxTrialDays - daysUsed) + " days left");
                      • 8. Re: Trial or Time limited versions
                        andosg_Ryan Level 1

                        Hi Paul!


                        Assuming the users do not reset their system timing. What is preventing them from looking up the key and changing the start date?

                        Could there be a way to encrypt the "key" so that no one can access the it? Like a password only the script knows.


                        I am guessing that so far, no script has been so valuable that it can be sold??

                        • 9. Re: Trial or Time limited versions
                          Paul Riggott Level 6

                          Yes it could be encrypted as an extra precaution, but as the script will be in binary (should be) the user would have to find the registry entry associated with the script and then they would not know the registry was being used as the vb file is deleted after it has been run.


                          This would script would stop most users, but there are always some clever people out there that can crack it.

                          • 10. Re: Trial or Time limited versions
                            xbytor2 Level 4

                            Paul is correct. The script has to be a binary. Using the registry this way is security via obscurity: most people won't think of looking there or easily guess the registry entry. That being said, there are tools out there that watch registry IO. Or so I've been told...


                            If you were to use encryption, DES should be fine. You just have to provide '0' encrypted as the first file (along with some random text) and fail if the file is not there. Using the registry won't work. An alternative is to use persistent app.get/setCustomOptions.


                            I am guessing that so far, no script has been so valuable that it can be sold??

                            I did something similar for a client in ActionScript a couple of years ago because they wanted to sell the script. I got it working but it was a serious pain and I won't do it again.

                            I (and many others) have made money writing scripts not selling scripts.

                            • 11. Re: Trial or Time limited versions
                              andosg_Ryan Level 1

                              Hi, Yes. I understand now that the script would have to be a binary. However, as i have limited capability with Window Registry, where in the Window's Registry would i find that particular "key" in Paul's script?


                              In addition, is there any ways to prevent circulation of your own script? ie, when i send it to a particular client, i do not wish that he sends it to multiple of his associates. I understand that Paul's script actually stop working after 30days but it can be sent to multiple other computers...


                              My intention is to simple have something like a script that cannot be shared with others, and also expires on its own. Would that be impossible?

                              • 12. Re: Trial or Time limited versions
                                Paul Riggott Level 6

                                Making the script machine dependant would be difficult, what you could do is send a script to the client to run and e-mail the output to you.

                                This script could get system information, scramble it so the user does not know what you have. Then use this information in the trial script to check it is running on the correct machine.


                                The key in the example (it can be changed to whatever you want it to be) can be found using Start (type in the search box) regedit

                                and navigate to HKEY_CURRENT_USER > Software > Trial

                                • 13. Re: Trial or Time limited versions
                                  andosg_Ryan Level 1

                                  I believe this might actually work! But what kind of system information is unique and yet accessible to a script? I have little experience in this matter.

                                  • 14. Re: Trial or Time limited versions
                                    Paul Riggott Level 6

                                    There are several things that you can get,, you can even get the Photoshop serial number, but that takes too much time. What I would suggest is use characters from the system variables.

                                    You can select more or less characters or from other enviroment setting and I would think this method would make it fairly unique to each machine.

                                    To see the different enviroment settings go to a DOS prompt and type in SET





                                    var sendMe = File(Folder.desktop + "/Please send me this.txt");
                                    var UN = $.getenv("username");
                                    var PA = $.getenv("path");
                                    var CN = $.getenv("computername");
                                    var testString = '';
                                    testString += UN[1] + UN[0]; //get the second and first character from Username
                                    testString += CN[parseInt(CN.length/2)]; //Get the character that is from half the length of the Computer Name
                                    testString += PA[3] + PA[parseInt(PA.length/3)]; //Get the character from a third of the length of the Path
                                    alert("Please send me 'Please send me this.txt' that is on your desktop");
                                    • 15. Re: Trial or Time limited versions
                                      Andy_Bat1 Level 1

                                      hello to all !

                                      prompt, where you can view the complete list of getenv ? In this script, the user can change the patch and the script does not work? I think that I need to bind to harware - motherboard, network card, etc.

                                      • 16. Re: Trial or Time limited versions
                                        Davide_Barranca Adobe Community Professional

                                        Try these:


                                        /* WINDOWS */
                                        $.writeln("ALLUSERSPROFILE  == "+  $.getenv("ALLUSERSPROFILE"));
                                        $.writeln("APPDATA  == "+  $.getenv("APPDATA"));
                                        $.writeln("CommonProgramFiles  == "+  $.getenv("CommonProgramFiles"));
                                        $.writeln("COMPUTERNAME  == "+  $.getenv("COMPUTERNAME"));
                                        $.writeln("ComSpec  == "+  $.getenv("ComSpec"));
                                        $.writeln("HOMEDRIVE  == "+  $.getenv("HOMEDRIVE"));
                                        $.writeln("HOMEPATH  == "+  $.getenv("HOMEPATH"));
                                        $.writeln("LOGONSERVER  == "+  $.getenv("LOGONSERVER"));
                                        $.writeln("NUMBER_OF_PROCESSORS  == "+  $.getenv("NUMBER_OF_PROCESSORS"));
                                        $.writeln("OS  == "+  $.getenv("OS"));
                                        $.writeln("Os2LibPath  == "+  $.getenv("Os2LibPath"));
                                        $.writeln("Path  == "+  $.getenv("Path"));
                                        $.writeln("PATHEXT  == "+  $.getenv("PATHEXT"));
                                        $.writeln("PROCESSOR_ARCHITECTURE  == "+  $.getenv("PROCESSOR_ARCHITECTURE"));
                                        $.writeln("PROCESSOR_IDENTIFIER  == "+  $.getenv("PROCESSOR_IDENTIFIER"));
                                        $.writeln("PROCESSOR_LEVEL  == "+  $.getenv("PROCESSOR_LEVEL"));
                                        $.writeln("PROCESSOR_REVISION  == "+  $.getenv("PROCESSOR_REVISION"));
                                        $.writeln("ProgramFiles  == "+  $.getenv("ProgramFiles"));
                                        $.writeln("SystemDrive  == "+  $.getenv("SystemDrive"));
                                        $.writeln("SystemRoot  == "+  $.getenv("SystemRoot"));
                                        $.writeln("TEMP  == "+  $.getenv("TEMP"));
                                        $.writeln("TMP  == "+  $.getenv("TMP"));
                                        $.writeln("USERDOMAIN  == "+  $.getenv("USERDOMAIN"));
                                        $.writeln("USERNAME  == "+  $.getenv("USERNAME"));
                                        $.writeln("USERPROFILE  == "+  $.getenv("USERPROFILE"));
                                        $.writeln("windir  == "+  $.getenv("windir"));
                                        /* MAC */
                                        function getSystemCommandStdout (command)
                                           var stdout = null;
                                           var tempFile = new File (Folder.temp + "/temp.txt");
                                           app.system (command + " > " + tempFile.fsName);
                                           if (tempFile.open ("r"))
                                              stdout = tempFile.read ();
                                              tempFile.close ();
                                              tempFile.remove ();
                                           return stdout;
                                        alert ("Photoshop environment variables:\r" + getSystemCommandStdout ("printenv"));


                                        They come from various threads in the PS-Scripts forum.



                                        Davide Barranca


                                        • 17. Re: Trial or Time limited versions
                                          Andy_Bat1 Level 1

                                          Tell me, how do I run "getmac" from JS ? I want to link your script to the network card

                                          • 18. Re: Trial or Time limited versions
                                            DBarranca Level 4

                                            Give this one a try:




                                            (I'm not on PC so I don't know what kind of params getmac needs)




                                            • 19. Re: Trial or Time limited versions
                                              Andy_Bat1 Level 1

                                              return 0, but open msdos window  and executed command...

                                              • 20. Re: Trial or Time limited versions
                                                Michael L Hale Level 5

                                                Yes app.system() will not return the output of the comand string. For something like this you could use a DOS redirect to file to save the output as a file the have the script read the file.


                                                app.system() is asynchronous so timing between the system call and reading the file will be a problem. And it is not supported on all version of Photoshop.

                                                • 21. Re: Trial or Time limited versions
                                                  Polycontrast Level 1

                                                  The function works fine to get the Photoshop environment variables in a Mac. These variables do not include the computer name/model. What approach can I use to identify the hardware in a script where the files are processed?



                                                  OSX MacBook Pro