برنامه ای که به عنوان برنامه آپدیت شده هست باید با اسم new.exe در کنار exe قبلی قرار بگیره و به جای NameOfProgram.exe هم نام درست برنامه خودتون را وارد کنید . تست کنید و نتیجه را بگید .
var
sl: TStringList;
begin
sl := TStringList.Create;
try
sl.Append(':Repeat');
sl.Append('del "' + Application.ExeName + '"');
sl.Append('if exist "' + ExtractFileName(Application.ExeName) +
'" goto Repeat');
sl.Append('Ren "'+ExtractFilePath(Application.ExeName)+'new.exe"' +' "NameOfProgram.exe"');
sl.Append('start "" "' + Application.ExeName +'"');
sl.Append('del "' + ExtractBackDir(Application.ExeName) + '\Del.bat"');
sl.SaveToFile(ExtractBackDir(Application.ExeName) + '\Del.bat');
ShellExecute(Handle, 'open', pchar(ExtractBackDir(Application.ExeName) + '\Del.bat'), '', '', 7);
Application.Terminate;
finally
sl.Free;
end;
تابع ExtractBackDir :
function ExtractBackDir(Path: string): string;
begin
Result := ExcludeTrailingPathDelimiter
(Copy(Path, 1, LastDelimiter('\', ExtractFileDir(Application.ExeName))));
end;