2015-05-19 49 views
0

我一直在問,從C#運行以下命令:運行的SharePoint STSADM命令

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

下面是代碼:

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命令在我的代碼中運行。

+0

它實際上不是順序。我使用了錯誤的連字符。用正確的替換它後,它的工作。 –

回答

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