UninstallAction Enumeration


The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Specifies what an installer should do during an uninstallation.

Namespace:   System.Configuration.Install
Assembly:  System.Configuration.Install (in System.Configuration.Install.dll)

public enum UninstallAction

Member nameDescription

Leaves the resource created by the installer as is.


Removes the resource the installer created.

The following sample creates a custom uninstaller that inherits the Installer class. In the overridden Uninstall function, the UninstallAction enumeration is set based on user input. If the input is "n", the custom uninstaller will not take any action on the resource in the event log entered by the user. Otherwise, it will remove the resource from the event log.

using System;
using System.Diagnostics;
using System.Collections;
using System.ComponentModel;
using System.Configuration.Install;

public class MyUninstallActionClass : Installer 
   EventLogInstaller myInstaller = new EventLogInstaller();

   // Override the 'Install' method.
   public override void Install(IDictionary savedState)
      Console.Write("Enter a new log to create (eg: MyLog ): ");
      myInstaller.Log = Console.ReadLine();
      Console.Write("Enter a source for log (eg: MySource ): ");
      myInstaller.Source = Console.ReadLine();
      Installers.Add( myInstaller );

   // Override the 'Commit' method.
   public override void Commit(IDictionary savedState)

   // Override the 'Rollback' method.
   public override void Rollback(IDictionary savedState)
   public override void Uninstall(IDictionary savedState)
      Console.Write("Enter a source from log to uninstall(eg: MySource ): ");
      myInstaller.Source = Console.ReadLine();

      Console.Write("Do you want to uninstall, press 'y' for 'YES' and 'n' for 'NO':");
      string myUninstall = Console.ReadLine();

      if( myUninstall == "n" )
         // No action to be taken on the resource in the event log.
         myInstaller.UninstallAction = System.Configuration.Install.UninstallAction.NoAction;
         // Remove the resource from the event log.
         myInstaller.UninstallAction = System.Configuration.Install.UninstallAction.Remove;
      Installers.Add( myInstaller );
   public static void Main()
      Console.WriteLine("Syntax for install: installutil.exe UninstallAction_NoAction_Remove_3.exe ");
      Console.WriteLine("Syntax for uninstall: installutil.exe /u "
         +"UninstallAction_NoAction_Remove_3.exe ");


.NET Framework
Available since 1.1
Return to top