Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deleting Applications After Terminate

Status
Not open for further replies.

paubri

Programmer
Apr 25, 2005
21
ZA
Hi.

I was wondering whether there is a way for a program to delete itself after it is terminated. At the moment I am doing it through the 'RunOnce' registry entry, but this only delete the application when the computer is restarted.

Any ideas?

Thanks,
British
 
Hey hey
If we are discuusing the ideas then here's one. Sorry I don't have time to write sample code at the moment, but the idea is quite simple. I was doing it when needed to make self updating application.
Idea:
Every time the application (APP1) is started, it starts another instance of itself with some param, say ProcessID (APP2). Once APP2 is started it does nothing but waits for APP1 to terminate (WaitForSingleObject). Once APP1 is closed/terminated, APP2 does all dirty things it needs to do and terminates.

That's all.

--- McMerfy
 
McMerfy, the problem with that approach is that I think Windows won't let you delete a program while it is running.

-D

A computer only does what you actually told it to do - not what you thought you told it to do.
 
Hey ther
I guess I didn't explain my idea full enough :)
well going further: Windows surely will not allow to delete a program that is currently running, but prior to starting a second instance of you APP you can copy it to another file, say, you program's name is MyApp.exe, when it starts it copies itself to MyApp2.exe and then starts MyApp2.exe with a param that you'd specify. Hence, when MyApp.exe terminates MyApp2.exe would catch that event as explained above, and MyApp2.exe would delete MyApp.exe. Though while typing this I ralized that that approach was good for selfupdating files and in your case that would still leave a copy of an application on a computer...
Sorry may be the idea wasn't that good.

--- McMerfy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top