Board index » delphi » Delet A prog while it's running

Delet A prog while it's running

I am trying to make an uninstal prog, which is almost done.
I am now stuck with trying to delete the prog itself once
it is finished , windows will not permit me to delete a
windows prog while it is running. Does anyone know a way
around this. Delphi 2.0 win 95.
All help is appreciated.

 

Re:Delet A prog while it's running


Quote
"S.Suffredini" <steven.suffred...@ukonline.co.uk> wrote:

Yes - Create an install.bat file that calls the uninstall program, and
then delete the uninstall program from the .bat file.  

Catch - there will always be a 'left-over' file on the system, in this
case, the batch file will be the left-over.

Good luck
D.

Quote
>I am trying to make an uninstal prog, which is almost done.
>I am now stuck with trying to delete the prog itself once
>it is finished , windows will not permit me to delete a
>windows prog while it is running. Does anyone know a way
>around this. Delphi 2.0 win 95.
>All help is appreciated.

Re:Delet A prog while it's running


This is a multi-part message in MIME format.

--------------54A07F2139C8
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Quote
S.Suffredini wrote:

> I am trying to make an uninstal prog, which is almost done.
> I am now stuck with trying to delete the prog itself once
> it is finished , windows will not permit me to delete a
> windows prog while it is running. Does anyone know a way
> around this. Delphi 2.0 win 95.
> All help is appreciated.

***********************

Hi, Steven!

Attached to this reply you find a small EXE-program: DOPAUSE.EXE. All it
does is a pause that you specify at the commandline. I refer to that
later.

I think I might have a solution to your problem. It may sound a little
complicated, but it should work. I've never tried this myself though,
it's a theoretical solution:

1. Let the Uninstaller delete all files but itself.
2. Let the Uninstaller create a BAT-file with the following:
     - DOPAUSE 5000  (giving your Uninstaller time to terminate)
     - DEL <uninstaller.exe>
     - DEL <the batch-file itself>
    (this should be done after any messages "Uninstallation is finished"
and so on...)
3. Finally, you let the Uninstaller run the BAT-file and then
immediately terminate. By the time the BAT-file reaches the DEL command
the Uninstaller should have terminated and therefore be erasable. No
traces of your application should then be left on the drive, since
BAT-files can erase themselves.

If you try this, please send me a message if it works. As I said, I've
never tried it before.

With hope of success,

Daniel Persson, Malmoe, Sweden
daniel.pers...@swipnet.se

--------------54A07F2139C8
Content-Type: application/octet-stream; name="Dopause.exe"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="Dopause.exe"

<encoded_portion_removed>
SwBDVFlQRQBBVE9MAEdFVERBVEUATERJVgBPVkVSRkxPVwBTTEVFUAA=
--------------54A07F2139C8--

Re:Delet A prog while it's running


Why don't you let your application do it on startup

eg: if FileExists(xxx) then deleteFile(xxx);

I admit it will slow down your Apps startup (a bit)

HTH,

--
Paul Motyer
pa...@pccity.com.au - now working!
Soft Stuff, Croydon, Australia, 3136

Douglas Troy <dt...@drsoftware.com> wrote in article
<5f48dc$...@camel2.mindspring.com>...

Quote
> "S.Suffredini" <steven.suffred...@ukonline.co.uk> wrote:

> Yes - Create an install.bat file that calls the uninstall program, and
> then delete the uninstall program from the .bat file.  

> Catch - there will always be a 'left-over' file on the system, in this
> case, the batch file will be the left-over.

> Good luck
> D.

> >I am trying to make an uninstal prog, which is almost done.
> >I am now stuck with trying to delete the prog itself once
> >it is finished , windows will not permit me to delete a
> >windows prog while it is running. Does anyone know a way
> >around this. Delphi 2.0 win 95.
> >All help is appreciated.

Re:Delet A prog while it's running


Quote
Paul Motyer wrote:

> Why don't you let your application do it on startup

> eg: if FileExists(xxx) then deleteFile(xxx);

> I admit it will slow down your Apps startup (a bit)

> HTH,

> --
> Paul Motyer
> pa...@pccity.com.au - now working!
> Soft Stuff, Croydon, Australia, 3136

> Douglas Troy <dt...@drsoftware.com> wrote in article
> <5f48dc$...@camel2.mindspring.com>...
> > "S.Suffredini" <steven.suffred...@ukonline.co.uk> wrote:

> > Yes - Create an install.bat file that calls the uninstall program, and
> > then delete the uninstall program from the .bat file.

> > Catch - there will always be a 'left-over' file on the system, in this
> > case, the batch file will be the left-over.

> > Good luck
> > D.

> > >I am trying to make an uninstal prog, which is almost done.
> > >I am now stuck with trying to delete the prog itself once
> > >it is finished , windows will not permit me to delete a
> > >windows prog while it is running. Does anyone know a way
> > >around this. Delphi 2.0 win 95.
> > >All help is appreciated.

I faced the same problem and solved it (in Delphi 1.0) with a batch file
approach...
1) The EXE creates the batch file, runs the batch file, and terminates.
2) The batch file persistently attempts to delete the EXE until its  
gone, then deletes itself.
3) Including command/c in the WinExec statement allows
SW_SHOWMINIMIZED    to work (otherwise, the batch file would be ugly -
especially "batch    file missing" after it commits suicide.

procedure kamikaze;
var
 p: array[0..100] of char;
 ts: tstringlist;
 exe: string;
 const
  bat='c:\kamikaze.bat';
begin
 exe:=paramstr(0);
 ts:=tstringlist.create;
 ts.add(':loop');
 ts.add('del '+exe);
 ts.add('if exist '+exe+' goto loop');
 ts.add('del '+bat);
 ts.savetofile(bat);
 winexec(strpcopy(p,'command.com /c '+bat),sw_showminimized);
 ts.free;
 application.terminate;
end;

Other Threads