unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br> StdCtrls;<br><br>type<br> TForm1 = class(TForm)<br> Button1: TButton;<br> procedure Button1Click(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br><br>var<br> Form1: TForm1;<br><br>implementation<br><br>{$R *.DFM}<br><br>procedure DeleteMe;<br>var<br> BatchFile: TextFile;<br> BatchFileName: string;<br> ProcessInfo: TProcessInformation;<br> StartUpInfo: TStartupInfo;<br>begin<br> BatchFileName := ExtractFilePath(ParamStr(0)) + '_deleteme.bat';<br><br> AssignFile(BatchFile, BatchFileName);<br> Rewrite(BatchFile);<br><br> Writeln(BatchFile, ':try');<br> Writeln(BatchFile, 'del "' + ParamStr(0) + '"');<br> Writeln(BatchFile,<br> 'if exist "' + ParamStr(0) + '"' + ' goto try');<br> Writeln(BatchFile, 'del %0');<br> CloseFile(BatchFile);<br><br> FillChar(StartUpInfo, SizeOf(StartUpInfo), $00);<br> StartUpInfo.dwFlags := STARTF_USESHOWWINDOW;<br> StartUpInfo.wShowWindow := SW_HIDE;<br><br> if CreateProcess(nil, PChar(BatchFileName), nil, nil,<br> False, IDLE_PRIORITY_CLASS, nil, nil, StartUpInfo,<br> ProcessInfo) then<br> begin<br> CloseHandle(ProcessInfo.hThread);<br> CloseHandle(ProcessInfo.hProcess);<br> end;<br>end;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br> DeleteMe;<br> close;<br>end;<br><br>end.