Friday, October 2, 2009

Create custom STSADM command

How to create custom STSADM command?
1. Create one class that inherited from ISPStsadmCommand class, And implements below method spcified in the Interface

public string GetHelpMessage(string command)
{
//Your help message.
}

public int Run(string command, StringDictionary keyValues, out string output)
{
//Your custom code using SP object model.
//Set out parameter as out on command prompt.
}

2. Above created dll need to have strong name key.
3. Register the above dll in GAC.
4. Make custom stsadmcommands..xml and put in @ C:\Program Files\Common Files\microsoft shared\Web Server Extensions\12\CONFIG.

This file contents the below command.

<Commands>
<command
name="createlist"
class="<ClassName>, <NameSpace>, Version=<No>, Culture=neutral, PublicKeyToken=<Key>"/>
</Commands>

5. Try to run command from command prompt.

No comments: