0

I've been asked to run the following command from C#:

stsadm -o gl-copylist -sourceurl "http://someurl" -targeturl "http://someurl" -includeusersecurity -haltonfatalerror -deletesource -includedescendants All –nofilecompression

Here is the code:

ProcessStartInfo startInfo = new ProcessStartInfo()
{
    WindowStyle = ProcessWindowStyle.Normal,
    FileName = "cmd.exe",
    Arguments = "/C " + command,
    CreateNoWindow = true,
    UseShellExecute = false,
    RedirectStandardError = true,
    RedirectStandardOutput = true
};

The command runs fine in a stand-alone command window, but always displays the standard "STSADM -o" help text when run from my console app.

Any idea why??

The gl-copylist command is an add-in to the standard SharePoint STSADM command. Could this be the reason? Other standard STSADM commands run in my code.

4

1 回答 1

2

在程序集中解析/验证命令行参数的方法似乎存在错误stsadm,特别是当在另一个includedescendants参数之前指定接受值的参数时,会发生以下错误:

命令行错误。

stsadm -o gl-copylist 
-sourceurl "http://server/sourceweb/listviewpage" 
-targeturl "http://server/targetweb" -includeusersecurity 
-haltonfatalerror 
-deletesource 
-includedescendants All   <- when this parameter is specified before another parameter    
–nofilecompression

一旦includedescendants参数指定为最后一个,则命令执行成功:

stsadm -o gl-copylist 
-sourceurl "http://server/sourceweb/listviewpage" 
-targeturl "http://server/targetweb" -includeusersecurity 
-haltonfatalerror 
-deletesource 
–nofilecompression
-includedescendants All   
于 2015-05-20T08:51:40.583 回答