procedure TForm1.Button1Click(Sender: TObject);
begin
if FileExists('Project1.exe') then
RenameFile('Project1.exe','2.exe');
end;
writeln(f, ':1');
writeln(f, format('Erase "%s"', [paramstr(0)]));
writeln(f, format('If exist "%s" Goto 1', [paramstr(0)]));
writeln(f, format('Erase "%s"', [FileName]));
RenameFile('Project1.exe','2.exe');на
RenameFile(<определенное имя>,<новое имя>);