Click here to Skip to main content
15,881,424 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
See more:
Hi,

I am creating an uninstaller which will delete some files and itself. It also needs to delete the folder in which it is placed. I am developing the uninstaller in C++ for Windows only.

I have found methods to delete folders and files but I am not able to find method which deletes the application itself and also deletes the folder that contains it.

Can anyone please guide me how can I achieve this??

Thanks
Posted

How did you create the uninstaller? Usually, you'd create an installer that is using the Windows Installer, and this will then handle the deletion of the installer after uninstalling.
 
Share this answer
 
Ok... Look here Self Deleting Exe... Many Many methods



http://www.catch22.net/tuts/self-deleting-executables[^]
 
Share this answer
 
v2
Comments
Philippe Mori 17-Apr-13 23:19pm    
Although it is possible to do self deletion if properly coded, a much better alternative is to create a real installer and Windows will handle everything properly. For consistency, it is better to always uses an installer so that program would appears in Add/Remove Programs.
iDebD 19-Apr-13 1:34am    
Best solutions are described here :)
[no name] 19-Apr-13 3:38am    
:)
create bat file named : test.bat and add in file this : "
C++
del c:\\example.exe
"
and from c++
C++
System::Diagnostics::Process::Start("c:\\test.bat");
//it wait some sec before gives error so 2nd line should be :
C++
Application::Exit();


i think it should work.. anyway u can test it...
 
Share this answer
 
Comments
Matthew Faithfull 17-Apr-13 6:40am    
No I don't think that's a good way at all. What the OP needs to do is shedule the unistaller.exe and its containing folder for deletion at the next restart using the correct SetupAPI. I don't have the details sufficient to post a solution in my mind right now but that is the way professional uninstallers work.
Mohibur Rashid 19-Apr-13 0:38am    
It would be a good method
I can't help but think for questions like these that something nefarious is planned. I agree with the others that a transactional based approach is better. Visual Studio has a WSYWIG installer project that is dead simple (for a simple application)

As I continue in my surprise, I also am surprised that the VS2008 sample code has an OpenGL project that rotates a cube.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900