最近工作中需要一个feature,在文档库中每个项目的下拉列表中添加一个菜单项,而且要求打包成wsp,我写了两个bat文件,一个用于安装部署,一个用于卸载。

1、安装部署:

@echo off
set /p wspLocation = Please input wsp file location:
set /p siteUrl = Please input site url:
cd C:\   
cd C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN
stsadm.exe -o addsolution -filename %wspLocation%
stsadm -o deploysolution -name myfeature.wsp -url %siteUrl% -immediate -allowCasPolicies
stsadm -o execadmsvcjobs
stsadm -o activatefeature -name MyFeature -url %siteUrl% -force

注:myfeature.wsp是解决方案的名称,MyFeature是此feature所在目录。此feature只部署在指定的某个站点集中,所以需要先指定wsp文件的位置及需要部署此解决方案的站点集地址,也因此而需要-allowCasPolicies,若要部署到所有站点集时用-allowGacDeployment

 

2、卸载:

@echo off
set /p siteUrl = Please enter site url:
cd C:\
cd C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN
stsadm -o retractsolution -name myfeature.wsp -url %siteUrl% -immediate
stsadm -o execadmsvcjobs
stsadm -o deletesolution -name myfeature.wsp