Autor Beitrag
Biarchiv
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 688



BeitragVerfasst: Mo 01.03.04 17:03 
Hallo,

ist es möglich das sich das ausgeführte Programm selbst löschen kann?
In Dos (int21h) ging das mal.
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Mo 01.03.04 17:09 
Nein... aber es geht mit Hilfe einer Batch-Datei, da diese sich selbst löschen kann...

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Mo 01.03.04 17:33 
in der faq findest du ne hilfe zu dem thema !
www.delphi-forum.de/viewtopic.php?t=11730

_________________
In the beginning was the word.
And the word was content-type: text/plain.
MaxiTB
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 679

Win2000, WinXp, Workbench ;-)
D7 Ent, VS2003 Arch.
BeitragVerfasst: Mo 01.03.04 18:45 
Wobei dieser Code angemerkt buggy ist - sollte mal ersetzt werden:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
procedure KillSelf(MainForm: TForm); 
var
 lBatchName: string;
begin 
 // Batchdatei in temporären Ordner erstellen
 lBatchName:=GetEnvironmentVariable('TEMP')+'\~DoggyBootshKillMyself~.bat';
 // Ähm ja - ich weiß man kann noch einen Tempnamen anfordern ;-)
 with TStringList.Create do try 
  Add(':Label1'); 
  Add('del "' + Paramstr(0) + '"'); 
  Add('if Exist "' + Paramstr(0) + '" goto Label1'); 
  Add('del "' + lBatchName + '"'); 
  SavetoFile(lBatchName); 
 finally 
  Free;
 end; 

 //Ausführen
 ShellExecute(MainForm.Handle, 'open', PChar(lBatchName), nil, nil, SW_HIDE); 
 //Beenden
 MainForm.Close; 
end;

Es ist nämlich unter NT üblich, daß normale User keine Schreibrechte im Applikationsverzeichnis haben.

_________________
Euer Mäxchen
Wer früher stirbt, ist länger tot.
MSCH
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1448
Erhaltene Danke: 3

W7 64
XE2, SQL, DevExpress, DevArt, Oracle, SQLServer
BeitragVerfasst: Mo 01.03.04 19:23 
das wird net gehen ! Selbst über eine Batch-Datei. Du rufst die Batchdatei nämlich noch auf,wenn dein Programm läuft (!) und dann kann dieses Programm nicht gelöscht werden, das NT Schreibzugriffe (Löschzugriffe gehören dazu) sperrt.

Ich versteh den Sinn aber nicht, warum sich ein Program selbst löschen sollte.
Korrekterweise sollte sowas mit Un-Install SOftware (e.g. InstallShield, liegt jeder Delphi bei ) durchgeführt werden.

Wenns denn ne Batchdatei sein soll, musste diese im Run-Once Registry Pfad verankert werden.

grez
msch

_________________
ist das politisch, wenn ich linksdrehenden Joghurt haben möchte?
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Mo 01.03.04 19:30 
Die Batchdatei läuft aber so lange, bis das Programm wirklich weg ist. Wartet also, bis das Programm beendet ist.

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
MSCH
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1448
Erhaltene Danke: 3

W7 64
XE2, SQL, DevExpress, DevArt, Oracle, SQLServer
BeitragVerfasst: Mo 01.03.04 19:40 
macht das Sinn? Sorry, aber wer programmiert denn sowas????
grez
msch

_________________
ist das politisch, wenn ich linksdrehenden Joghurt haben möchte?
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Mo 01.03.04 19:43 
Der Source stammt von GruppeCN. Wenn Du eine bessere Idee hast, wie man sein eigenes Programm sofort nach Beendigung desselbigen löschen kannst, kannst Du ja gerne einen Beitrag in die FAQs setzen.
Ansonsten: Der Source ist besser als gar nichts, oder?

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
MSCH
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1448
Erhaltene Danke: 3

W7 64
XE2, SQL, DevExpress, DevArt, Oracle, SQLServer
BeitragVerfasst: Mo 01.03.04 19:57 
msdn.microsoft.com/l.../base/movefileex.asp

also zumindest unter XP/NT/2000

ausblenden Delphi-Quelltext
1:
MoveFileEx('c:\windows\command.com','nul',MOVEFILE_DELAY_UNTIL_REBOOT)					

grez
msch

_________________
ist das politisch, wenn ich linksdrehenden Joghurt haben möchte?
MaxiTB
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 679

Win2000, WinXp, Workbench ;-)
D7 Ent, VS2003 Arch.
BeitragVerfasst: Mo 01.03.04 19:57 
Hm - hab nochmals selber drüber gegrübbelt und stimmt schon - wenns ein normaler User ist, dann ist meine Variante des Codes ein Resourcenfresser (weil ja die Batch-Datei niemals die Exe löschen kann). Also lieber meinen Code wieder vergessen.

Und ich muß auch MSCH recht geben - mal abgesehen davon das es funktioiniert mit Admin-Rechten, was bringts wirklich ? Programme mit Selbstmordgedanken ohne Userzutun sind schon ein bisserl eigenartig, weil da fallen mir nur zwei auf die schnelle ein:

:arrow: Installationsprogramme.
:arrow: Trojaner.

_________________
Euer Mäxchen
Wer früher stirbt, ist länger tot.
ErnestoChe
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 528

Win 2000 pro, CRUX 2.0
Delphi 6 Pers, Open K3
BeitragVerfasst: Mo 01.03.04 21:17 
Hallo,

@MSCH, MaxiTB
Ich hab ein Online-Update für unser Programm-Paket geschrieben. Es sucht automatisch nach Updates, lädt sie runter und installiert sie. Nun muss sich das Tool hin und wieder selbst updaten. Aber während das Programm läuft, kann die Exe-Datei nicht durch eine andere gleichnamige Exe-Datei ersetzt werden.

Ich habe das so gelöst, dass die gepatchte Exe-Datei unter einem bestimmten, anderen Namen in den Programmordner kopiert wird. Beim Schließen des Programms wird geprüft ob eine Exe-Datei mit diesem bestimmten Namen im Programmordner existiert, falls ja wird ein Batchfile erzeugt welches die Programm-Exe löscht und anschließend die heruntergeladene, gepatchte Exe umbenennt zur urpsrünglichen Programm-Exe.

MFG

- Ernesto -
Biarchiv Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 688



BeitragVerfasst: Mi 03.03.04 16:31 
Hallo,

habe mir gedacht wenn die Datei gecrackt wird
das per Zufall mal die EXE weg ist. Sonst aber das mit:

MoveFileEx('c:\windows\command.com','nul',MOVEFILE_DELAY_UNTIL_REBOOT)

ist nicht schlecht.