从C#控制台运行SharePoint STSADM命令

从C#控制台运行SharePoint STSADM命令,c#,sharepoint,stsadm,C#,Sharepoint,Stsadm,我被要求从C#运行以下命令: 代码如下: ProcessStartInfo startInfo = new ProcessStartInfo() { WindowStyle = ProcessWindowStyle.Normal, FileName = "cmd.exe", Arguments = "/C " + command, CreateNoWindow = true, UseShellExecute = false, RedirectSta

我被要求从C#运行以下命令:

代码如下:

ProcessStartInfo startInfo = new ProcessStartInfo()
{
    WindowStyle = ProcessWindowStyle.Normal,
    FileName = "cmd.exe",
    Arguments = "/C " + command,
    CreateNoWindow = true,
    UseShellExecute = false,
    RedirectStandardError = true,
    RedirectStandardOutput = true
};
该命令在独立的命令窗口中运行良好,但从我的控制台应用程序运行时,始终显示标准的“STSADM-o”帮助文本

知道为什么吗


gl copylist命令是标准SharePoint STSADM命令的附加模块。这可能是原因吗?其他标准的STSADM命令在我的代码中运行。

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

命令行错误


实际上这不是命令。我用错了连字符。用正确的替换后,它就可以工作了。
ProcessStartInfo startInfo = new ProcessStartInfo()
{
    WindowStyle = ProcessWindowStyle.Normal,
    FileName = "cmd.exe",
    Arguments = "/C " + command,
    CreateNoWindow = true,
    UseShellExecute = false,
    RedirectStandardError = true,
    RedirectStandardOutput = true
};
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
stsadm -o gl-copylist 
-sourceurl "http://server/sourceweb/listviewpage" 
-targeturl "http://server/targetweb" -includeusersecurity 
-haltonfatalerror 
-deletesource 
–nofilecompression
-includedescendants All