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.
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…
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?
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");
}
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??
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.
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.
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?
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
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");
North America
Europe, Middle East and Africa
Asia Pacific