SRL Archive - SRL Snippets

Self-Deleting Script


Kevin

2013-06-18 13:27:50

In case anyone feels like releasing a script during a testing phase and enforcing people to stop using it (which I may plan on before long…), this little snippet can A)Delete the currently running script and/or B)Only run the delete after a certain date.

Thanks to @The Killer for grabbing the date.

procedure DeleteSelf;
var
fh: integer;
begin
if(ScriptFile='')then
TerminateScript();
fh := Rewritefile(ScriptPath + ScriptFile, true);
WriteFileString(fh, '');
CloseFile(fh);
TerminateScript();
end;

procedure CheckDate;
var
Year, Month, Day: Word;
iYear, iMonth: Integer;
begin
DecodeDate(Date, Year, Month, Day);
iYear := StrToInt(ToStr(Year));
iMonth := StrToInt(ToStr(Month));
if ((iYear > 2013) or (iMonth > 7)) then//This will make the script delete itself at any point August 1st 2013 or later - so long as you call this method.
DeleteSelf;
end;

Janilabo

2013-06-18 15:30:33

Ey Kevin,

Glad to see you sharing all these useful/cool little snippets with the community!
Looks like you are having some great ideas lately. :)

-Jani

rj

2013-06-18 15:36:25

This is actually pretty cool, not sure if its allowed though?

Kevin

2013-06-18 15:54:36

From: Janilabo
Ey Kevin,

Glad to see you sharing all these useful/cool little snippets with the community!
Looks like you are having some great ideas lately. :)

-Jani


Thank you, I really wish to release some much bigger things soon that these contribute towards :) (also thanks for pointing me to ScriptFile :p )

From: Officer Barbrady
This is actually pretty cool, not sure if its allowed though?


Why wouldn't this be allowed?

J J

2013-06-18 15:58:21

The problem with these kind of things is that all scripts are open source. Someone could easily remove this from the script. Your best bet would be to have some kind of authentication with a server and encrypt all scripts and have multiple simba files or something or even download a part from your server :P But this is a nice snippet that will work in most cases :D

Kevin

2013-06-18 16:05:53

From: J J
The problem with these kind of things is that all scripts are open source. Someone could easily remove this from the script. Your best bet would be to have some kind of authentication with a server and encrypt all scripts and have multiple simba files or something or even download a part from your server :P But this is a nice snippet that will work in most cases :D


I easily agree with this, however I stand by the fact that (at least when I will use it), if someone was smart enough to not only read through my script, but recognize what it does, then they deserve to keep it :)
Encrypting the scripts would be against our standards, however, it wouldn't be hard to alter the typical auto-updater to simply rewrite the current running script, and when public releases are done, your final submit is a blank file - causing the typical update to override everyone.

The Mayor

2013-06-18 16:14:13

From: Kevin
Why wouldn't this be allowed?


I think RJJ is thinking antileech. Antileech is basically to prevent a leecher from running a script. This prevents them from running it after a certain date, but it doesn't stop them running it at all, which is what a typical antileech does.

Janilabo

2013-06-18 16:22:25

From: Kevin
Thank you, I really wish to release some much bigger things soon that these contribute towards :) (also thanks for pointing me to ScriptFile :p )
Looking forward to those bigger things mate!

No problem, glad to see you have given that function some interesting "jobs". :p

xtrapsp

2013-06-19 09:29:31

From: The Mayor
I think RJJ is thinking antileech. Antileech is basically to prevent a leecher from running a script. This prevents them from running it after a certain date, but it doesn't stop them running it at all, which is what a typical antileech does.


But it isn't anti-leech