Problem Source: http://www.cnblogs.com/del/archive/2008/08/12/1266368.html#2028808
Unit unit1; interfaceuses windows, messages, sysutils, variants, classes, graphics, controls, forms, dialogs; Type tform1 = Class (tform) Procedure formdestroy (Sender: tobject); end; vaR form1: tform1; implementation {$ R *. DFM} procedure tform1.formdestroy (Sender: tobject); const batfile = 'tmp. bat '; begin chdir (extractfilepath (application. exename); with tstringlist. create do begin add ('del '+ application. exename); add ('del '+ batfile); savetofile (batfile); free; end; winexec (batfile, sw_hide); end.
Modify the response Name:
Procedure tform1.formdestroy (Sender: tobject); const batfile = 'tmp. bat '; oldname = '123.exe'; // if this is the name to be restored, begin if extractfilename (application. exename) = oldname then exit; chdir (extractfilepath (application. exename); with tstringlist. create do begin add ('ren' + application. exename + ''+ oldname); add ('del '+ batfile); savetofile (batfile); free; end; winexec (batfile, sw_hide); end;