• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Trial or Time limited versions

Explorer ,
Aug 08, 2011 Aug 08, 2011

Copy link to clipboard

Copied

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.

TOPICS
Actions and scripting

Views

4.6K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Valorous Hero ,
Aug 08, 2011 Aug 08, 2011

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 09, 2011 Aug 09, 2011

Copy link to clipboard

Copied

Would not changing the system date get around this?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Aug 09, 2011 Aug 09, 2011

Copy link to clipboard

Copied

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…

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 09, 2011 Aug 09, 2011

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Aug 09, 2011 Aug 09, 2011

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 07, 2012 Apr 07, 2012

Copy link to clipboard

Copied

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Apr 08, 2012 Apr 08, 2012

Copy link to clipboard

Copied

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");

}


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 08, 2012 Apr 08, 2012

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Apr 08, 2012 Apr 08, 2012

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Apr 08, 2012 Apr 08, 2012

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 08, 2012 Apr 08, 2012

Copy link to clipboard

Copied

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Apr 08, 2012 Apr 08, 2012

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 11, 2012 Apr 11, 2012

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Apr 11, 2012 Apr 11, 2012

Copy link to clipboard

Copied

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");

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 06, 2013 Oct 06, 2013

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Oct 07, 2013 Oct 07, 2013

Copy link to clipboard

Copied

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

Davide Barranca - PS developer and author
www.ps-scripting.com

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 28, 2013 Oct 28, 2013

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Oct 29, 2013 Oct 29, 2013

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 30, 2013 Oct 30, 2013

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Oct 30, 2013 Oct 30, 2013

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jun 05, 2018 Jun 05, 2018

Copy link to clipboard

Copied

LATEST

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?

Environment

OSX MacBook Pro

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines