Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


How to uninstall a program?

Posted on 1999-07-27
Medium Priority
Last Modified: 2010-04-04
I would need to do this: from my application I want to be able to uninstall the application itself, deleting its executable from HD.
The problem is: it's impossible to delete the executable while it's still running.
I was wondering if there's a way to tell Windows to delete a file and a directory when it's starting up. I mean: I noticed that many installation or uninstallation programs ask the user to reboot the system, I think because they cannot remove programs currently running otherwise (think of uninstalling a program a part of which is running in the system tray...).
My question is: do I have to set any key in the registry or something like this to tell Windows to remove a file and a directory (the executable and the folder it's installed in) upon startup?
Otherwise, is there any way to uninstall my application without having to use an external executable to delete it?
Thanks in advance,
Question by:mauromol
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2

Accepted Solution

CalvinDay earned 300 total points
ID: 1391396
Have your uninstall program remove everything it needs and then remove the uninstall program upon reboot by using this:

  fRun:=' /c del c:\windows\Uninstall.EXE';
  with TRegIniFile.Create('') do


Author Comment

ID: 1391397
As I would need to uninstall the program from itself, I may do in this way: let's call program A my program and program B the uninstall program.
I could run B from A, passing to it a handle of A. Then, I could terminate A from B using that handle, so that I can after delete A's executable from B.
But how to do this?

Expert Comment

ID: 1391398
Possibly, but it is best to have the user start the uninstaller. I always put my program on the start programs menu with the uninstaller following. In your case, you still need to get rid of B.

Author Comment

ID: 1391399
The fact is the installer/uninstaller I'm using must perform many operations before simply uninstalling the program. I integrate a lot of funtions in it, among which the uninstall features.
However, I thought I may put two calls into RunOnce registry key, one to delete this installer/uninstaller and one to delete its subfolder in c:\Program Files...
Thanks CalvinDay!

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question