SRL Archive - Help and Support

Script deletetion for good.


P1nky

2012-02-21 08:39:50

Hallow Mates, I was wondering if it is possible to delete a script/file located anywhere in a Computer (Downloads folder/Desktop/Scripts folder/etc..), using SIMBA.

JuKKa

2012-02-21 08:56:27


begin
if DeleteFile(apppath+'Rimmington0.bmp')then
writeln('file deleted');
end.

it did delete my bitmap, that i had saved earlier in my Simba folder.
to delete a script something like deletefile(scriptpath+'.simba'); i think

but scriptpath is empty if the script is not saved.

P1nky

2012-02-21 09:11:52

See that is the part I had down, but I wanted the code to delete the existence of the script located anywhere in the Computer; Les' say there is a copy of the script on the desktop & Script folder, how would I get it to delete the script from the folder and desktop?

Brandon

2012-02-21 10:22:45

Hey.. I'm not sure why GetFiles won't work.. there may be a bug in it.. OR I could be using it wrong.. but the solution is definitely the below code.


program FileDeleter;


Function UpdaterCheck: boolean;
var
Files: TStringArray;
I: Integer;
begin
//If Script out of date.. then.. delete it.. or whatever reason you want to delete them :S

Result:= False;
Files := GetFiles('C:/Simba/Scripts', '.simba');
For I := 0 To High(Files) do
if (ExecRegExpr('Waterfiends | waterfiends', Files[I])) then
if DeleteFile(Files[I]) then
Result:= True;
end;

begin
UpdaterCheck;
end.

Dgby714

2012-02-21 11:08:37

program new;

function ExtractFileInfo(const Filename: string): TStringArray;
var
StrArr, _Temp: TStringArray;
begin
SetLength(Result, 2);
StrArr := Explode('\', Filename);
_Temp := Explode('.', StrArr[High(StrArr)]);
Result[1] := _Temp[High(_Temp)];
SetLength(StrArr, Length(StrArr) - 1);
Result[0] := Implode('\', StrArr) + '\';
end;

function DeleteFiles(const Method, Filename: string): boolean;
var
H, I: LongInt;
Files, Info: TStringArray;
V: TVariantArray;
begin
Result := False;
SetLength(V, 1);

Info := ExtractFileInfo(Filename);

Files := GetFiles(Info[0], Info[1]);
H := High(Files);
for I := 0 to H do
begin
V[0] := Files[I];
if (CallProc(Method, V)) then
if (DeleteFile(Files[I])) then
Result := True;
end;
end;

function MyCheckMethod(const Filename: string): boolean;
begin
Result := False;
WriteLn(Filename);
end;

begin
DeleteFiles('MyCheckMethod', 'C:\Users\John\Desktop\Simba\Scripts\script.simba');
end.

Brandon

2012-02-21 11:24:46

Dgby wouldn't that have to have a static location and script name? If I'm correct what he wants to do is to iterate through all folders on the computer, find simba scripts.. if they match the name of his, then delete :S??

Edit: MYCheckMethod.. Always returns false so the CallProc won't execute??

Dgby714

2012-02-21 11:27:37

From: ggzz
Dgby wouldn't that have to have a static location and script name? If I'm correct what he wants to do is to iterate through all folders on the computer, find simba scripts.. if they match the name of his, then delete :S??

And I think you meant:
if (CallProc(MyCheckMethod, V)) then <— You don't have a function called Method & MyCheckMethod returns false always?


Method was a variable? CallProc needs a string as the first parameter.

And do you know how long it takes to search the whole harddrive? FOREVER!
I already have made a GetFiles_R().. It is toooooooo sloooooow

Searching just the scripts directory or the directory of the current script is fine.

I checked it, it works fine how I posted it.

kitchenrange

2012-02-21 12:07:17

couldn't someone just rename the file to get around this?

E: gotcha… nvm.

Dgby714

2012-02-21 12:29:02

From: kitchenrange
couldn't someone just rename the file to get around this?


He prob just wants it for his updater, to delete old versions of the script…

P1nky

2012-02-21 17:01:26

From: Dgby714
He prob just wants it for his updater, to delete old versions of the script…


To be honest, I just want my PestControl to be only Members+ for now.
And get the PestControl games to become steady like it was when weequ moved his PCer to Members+.

Harry

2012-02-21 17:09:21

Making the PCer attack portals would even out the issues you have with the bots ruining PC. Deleting files automatically is a recipe for disaster.

P1nky

2012-02-21 17:16:28

From: Harry
Making the PCer attack portals would even out the issues you have with the bots ruining PC. Deleting files automatically is a recipe for disaster.


I was thinking about that, and yes, I do think it be wrong for me to do that.
I'll start working on it when I get time.

Thanks for your suggestion Harry.

weequ

2012-02-21 20:23:50

Yeah portal attacking is the way to go. That's what I was supposed to do but I don't have the motivation nor time anymore. I hope I'll be able to add portal attacking to my pcer in a couple of months :p I shall move mine to public scripts if I do so.