Click here to Skip to main content
15,879,239 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
The Winforms application on which i am working creates some log files during its execution. The problem is when a user uninstall this application from the system, all the folders and log file created by the application remains on the system.
Is there any way(either during the creation of installer or thru some code) that with the uninstalltion of the file we can remove all the log files created by the application.
Posted

Using Visual Studio 2005/2008, you don’t need to write any code to add a uninstall option for a Setup project (Yes I know some people can write code to do it)

1) In the Setup Project –> File System windows –> Right Click “File System on Target machine” –> add a Special Folder, select System Folder;

2) Into this system folder Add a file. Browse for msiexec.exe from local System32 folder and add it. Override default properties of this file as follows:

Condition:=Not Installed (make sure you put ‘Not Installed’ exactly like that, same case and everything),
Permanent:=True,
System:=True,
Transitive:=True,
Vital:=False.

3) Create a new shortcut under the ‘Users Program Menu’, Set Target to the System Folder which you created in the step 1. and point it’s at the msiexec.exe. Rename the shortcut to ‘Uninstall Your Application’. Set the Arguments property to /x{space}[ProductCode].

5) Build the project, ignore warning about the fact that msiexec should be excluded, DONT exclude it or the setup project wont build.
 
Share this answer
 
Comments
Mateen Khan 5-Mar-12 23:49pm    
I used the steps given by you to add uninstall option for user.But When i click the "Uninstall Your Application". It simply opens the System32 folder in windows explorer.
Please if you can check the steps and revert back.
When the installed application creates a log file or some other files, then during uninstall it is not removed. During uninstall only the files and registry entries which are created gets deleted.
So for deleting any file or data which was created during program execution, you need to create a custom action which will be called during uninstall. This custom action will deleted all the files which is going to be created by application.

Following link will help you for creating custom action
Custom Action in Visual Studio setup projects[^]

http://www.simple-talk.com/dotnet/visual-studio/visual-studio-setup---projects-and-custom-actions/[^]
 
Share this answer
 
Comments
Mateen Khan 6-Mar-12 1:04am    
Hi Chandrakantt,
I went through the links. Can we create custom action in c# .NET instead of c ? I am having difficulty in understanding the Win32 project.
Chandrakantt 6-Mar-12 1:13am    
Yes surely you can create a custom action in .Net.
You can go through the second link which I have provided and also the link which I am providing below.
http://www.simple-talk.com/dotnet/visual-studio/getting-started-with-setup-projects/

http://www.codeproject.com/Articles/26091/Install-Windows-Service-using-Custom-Actions

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