Saturday, October 2, 2010

How to install and uninstall farm solution through STSADM on SharePoint 2010

We all know to install and uninstall a farm solution through Powershell on SharePoint 2010 is easy, but how to do it through STSADM? That's not as easy as the one on MOSS 2007.

When running the command: "stsadm -o execadmsvcjobs", quite possible you will get the error message:

"The administration service is running so all administration jobs will be run in the timer service"

When running "stsadm -o deletesolution -name SolutionName.wsp -override", it may end up with error message:

"The solution cannot be removed when a job is scheduled or running. SolutionName.wsp: The removal of the solution failed."

It seems we just need to stop the administration service first.  However, if we run:

stsadm -o provisionservice -action stop -servicename SPAdminV4 -servicetype "Microsoft.SharePoint.Administration.SPAdministrationService, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"

We will get:

"This service is required for most operations, and is not configurable with this command.  Please refer to the online help for the Microsoft.SharePoint.Administration.SPAdministrationService, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c."

Interesting. So what we can do now? Thanks for the post here SharePoint 2010 & Service Provisioning (by Bryan Porter), it turns out we need to stop the service through "net stop" command.

Below is the full cmd script.

--------------------------------------------------
To install a farm solution and then activate the feature:


@SET STSADM="c:\program files\common files\microsoft shared\web server extensions\14\bin\stsadm"


cd C:\theFolderOfTheWspFile
C:


net stop SPAdminV4


%STSADM% -o addsolution -filename .\solutionName.wsp
%STSADM% -o execadmsvcjobs


%STSADM% -o deploysolution -name solutionName.wsp -immediate -allowgacdeployment
%STSADM% -o execadmsvcjobs


%STSADM% -o activatefeature -name solutionName -url http://SiteCollectionUrl
%STSADM% -o execadmsvcjobs


net start SPAdminV4


pause

--------------------------------------------------
To deactivate a featuren and then uninstall the farm solution

@SET STSADM="c:\program files\common files\microsoft shared\web server extensions\14\bin\stsadm"

net stop SPAdminV4

%STSADM% -o deactivatefeature -name solutionName -url http://SiteCollectionUrl -force
%STSADM% -o execadmsvcjobs

%STSADM% -o retractsolution -name solutionName.wsp -immediate
%STSADM% -o execadmsvcjobs

%STSADM% -o deletesolution -name solutionName.wsp -override
%STSADM% -o execadmsvcjobs

net start SPAdminV4

pause



Update (07/04/2011):

For workflow related solution and feature, we need to run the code below to refresh the SharePoint object cache.


net stop "SharePoint 2010 Timer"
net start "SharePoint 2010 Timer"

No comments:

Post a Comment