Skip navigation
GreenShoot2
Currently Being Moderated

Trial or Time limited versions

Aug 8, 2011 6:58 AM

Hi

 

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.

 
Replies
  • Currently Being Moderated
    Aug 8, 2011 10:23 AM   in reply to GreenShoot2

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

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 9, 2011 7:48 AM   in reply to GreenShoot2

    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…

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 9, 2011 8:22 AM   in reply to GreenShoot2

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 7, 2012 7:53 AM   in reply to Paul Riggott

    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?

     

    Conditions:

    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.

     

    Possible?

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 8, 2012 2:26 AM   in reply to andosg_Ryan

    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).

     

     

    main();
    function main(){
     if(!$.os.match(/windows/gi)){
         alert("Sorry this is a Windows only script");
         return;
         }
    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();
    VBFile.open('w');
    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'
    VBFile.write(VB);
    VBFile.close();
    VBFile.execute();
    while(!daySince1970.exists){}
    $.sleep(100);
    var dayNow = (Math.round(new Date().getTime()/1000/86400));
    daySince1970.open('r');
    var originalDay = Number(daySince1970.read());
    daySince1970.close();
    if(dayNow < originalDay) {
        alert("Someone has reset the time!");
        return;
        }
    var daysUsed = (dayNow + 1 ) - originalDay;
    if(daysUsed > maxTrialDays){
        alert("Your trial period has expired\rThank you for trying this script\rwww.mysite.co.uk");
        return;
        }
    alert("This is the trial code\rLucky you\rYou have "+ (maxTrialDays - daysUsed) + " days left");
    }
    
    
     
     
    |
    Mark as:
  • Currently Being Moderated
    Apr 8, 2012 4:45 AM   in reply to Paul Riggott

    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??

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 8, 2012 5:07 AM   in reply to andosg_Ryan

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 8, 2012 7:55 AM   in reply to Paul Riggott

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 8, 2012 8:21 AM   in reply to xbytor2

    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?

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 8, 2012 8:41 AM   in reply to andosg_Ryan

    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

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 11, 2012 3:55 AM   in reply to Paul Riggott

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 11, 2012 4:11 AM   in reply to andosg_Ryan

    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

     

    IE:-

     

     

    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
    sendMe.open('w');
    sendMe.writeln(testString);
    sendMe.close();
    alert("Please send me 'Please send me this.txt' that is on your desktop");
    
    
     
    |
    Mark as:
  • Currently Being Moderated
    Oct 6, 2013 11:56 PM   in reply to Paul Riggott

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 7, 2013 3:28 PM   in reply to Andy_Bat1

    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.

    Cheers

     

    Davide Barranca

    www.davidebarranca.com

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 28, 2013 2:26 AM   in reply to Davide_Barranca

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

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 29, 2013 3:39 PM   in reply to Andy_Bat1

    Give this one a try:

     

    app.system("getmac");
    

     

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

     

    Davide

    www.davidebarranca.com

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 30, 2013 3:03 AM   in reply to DBarranca

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

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 30, 2013 1:12 PM   in reply to Andy_Bat1

    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.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points