The STSADM utility enables many administrative operations in Windows SharePoint Services that cannot be done with the Central Administration application. With Windows SharePoint Services 3.0 you can extend the functionality of the STSADM utility by adding your own operations and command line parameters with simple projects using any .NET language.
Microsoft.SharePoint.StsAdmin namespace is used for the creation of stsadm command line which interacts with SharePoint API. Then we need to implement Interface ISPStsadmCommand which consists of two methods GetHelpMessage and Run .
public class class name : ISPStsadmCommand
{
public string GetHelpMessage(string command)
{
}
public int Run(string command, System.Collections.Specialized.StringDictionary keyValues, out string output)
{
}
}
The GetHelpMessage method returns a string value containing help and usage information for the custom operation.
The Run method will take a StringDictionary as argument from stsadm.exe which consists of key/value pairs containing all named parameters, values and flags input from the administrator. The Run method also takes an out type parameter which will be used to return message to console window during execution.
One class for each custom stsadm.exe operation, and each of these classes must implement the ISPStsadmCommand interface. Each class that implements the ISPStsadmCommand interface is required to contain a GetHelpMessage method and a Run method.
For Deployment we need a assembly which is our complied code has to place in Global assembly cache and a configuration file which is a simple xml file starts with <commands> element as root element and <command> as sub elements.
Command element has attributes which are name and class.
Name attribute is for operationcommand name and class indicates the class name, assembly name, version and token key.
Configuration files must follow the well known naming convention stsadmcommands.customcommands.xml where customcommands is arbitrary but must be unique. Through this naming convention for configuration files, stsadm.exe implements a pluggable architecture for declaring custom operations.
And Place this configuration file in 12 hives CONFIG folder. We can begin extending OOB stsadm.exe functionality with our own custom operations.
Scenario which we have used here is to change the OOB list's newpage, editpage and display page. There is no OOB command for changing those properties. And we can change using SharePoint designer in order to avoid the manual process we can use
this custom stsadm command. |