Skip to content

Determine if Feature is being activated via STSADM or the browser

July 1, 2011

Did you ever wanted to know in a FeatureActivated event if the feature is being activated via STSADM -o activatefeature … command or through the browser?

Probably not, but if yes this is the way to do it:

	public class MyFeatureReceiver : SPFeatureReceiver
	{
		private bool IsExecutedBySTSADM
		{
			get 
			{
				return (SPContext.Current == null);
			}
		}
	
		public override void FeatureActivated(SPFeatureReceiverProperties properties)
		{					
			if (IsExecutedBySTSADM)
			{				
			}	
		}
	}
Advertisements
2 Comments
  1. Rahul permalink

    Can u pls give me the stsadm command for determining whether the feature is activated or not ?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: