Uninstalling a Feature




Go back to index

How to uninstall a Feature


Following code block explains how to programmatically uninstall a Feature from the farm. You can either give the name or Guid of the feature to be uninstalled.

      using System;
      using SPTool.Library;
      
      namespace SPTool.Test
      {
          class Program
          {
              static void Main(string[] args)
              {
                  SPTFarm farm = new SPTFarm();
                  
                  // Uninstall the feature
                  SPTReturn returnObj = farm.UninstallFeature("SPTool.Site.Config", false);

                  // Uninstall the feature using Guid
                  //returnObj = farm.UninstallFeature(new Guid("3FEF8D22-F191-41b6-8F1D-5D50D15BD2A6"), false);

                  // Check the status of uninstalling the feature
                  if (returnObj.State == SPTState.Success)
                  {
                      // Uninstalling Feature Successful
                  }
                  else
                  {
                      // Uninstalling Feature Failed
                  }
              }
          }
      }
      


Go back to index