This documentation is archived and is not being maintained.
UninstallAction Enumeration
Visual Studio 2010
Specifies what an installer should do during an uninstallation.
Assembly: System.Configuration.Install (in System.Configuration.Install.dll)
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.dll> #using <System.Configuration.Install.dll> using namespace System; using namespace System::Diagnostics; using namespace System::Collections; using namespace System::ComponentModel; using namespace System::Configuration::Install; [RunInstaller(true)] ref class MyUninstallActionClass: public Installer { private: EventLogInstaller^ myInstaller; public: MyUninstallActionClass() { myInstaller = gcnew EventLogInstaller; } // Override the 'Install' method. virtual void Install( IDictionary^ savedState ) override { 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 ); Installer::Install( savedState ); } // Override the 'Commit' method. virtual void Commit( IDictionary^ savedState ) override { Installer::Commit( savedState ); } // Override the 'Rollback' method. virtual void Rollback( IDictionary^ savedState ) override { Installer::Rollback( savedState ); } virtual void Uninstall( IDictionary^ savedState ) override { 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->Equals( "n" ) ) { // No action to be taken on the resource in the event log. myInstaller->UninstallAction = UninstallAction::NoAction; } else { // Remove the resource from the event log. myInstaller->UninstallAction = UninstallAction::Remove; } Installers->Add( myInstaller ); Installer::Uninstall( savedState ); } }; int 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 " ); }
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Show: