从代码调用DTExec不起作用,但命令提示符不起作用

时间:2015-11-30 19:35:10

标签: c# ssis dtexec

我正在编写一个应用程序,它将DTExec作为另一个用户运行,以运行已部署到服务器的SSIS包。目前,我根据某些组件是否已启用生成参数字符串。

这是我的问题......运行DTExec时,我使用以下代码:

        System.Security.SecureString password = PasswordBox.SecurePassword;
        string DTExecArgs = rules.GetDTExecArgsHarden(); // generate the arguments


        //redirect standard output stream of the child process
        p.StartInfo.UseShellExecute = false;
        p.StartInfo.RedirectStandardOutput = true;
        p.StartInfo.FileName = @"C:\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn\DTExec.exe";
        p.StartInfo.Arguments = DTExecArgs;
        p.StartInfo.UserName = "hello123";
        p.StartInfo.Domain = "mydomain";    
        p.StartInfo.Password = password;
        p.Start();

当我运行此代码时,我收到错误“存根收到坏数据”,程序崩溃。当我进入调试模式时,我可以复制作为命令接收的字符串,然后以用户hello123运行命令提示符并键入dtexec [此处粘贴命令],它根本不运行任何问题。这让我相信命令是合理的。以下是命令变量内容:

/ISServer "\SSISDB\ServerUpdating\UpdateRun\Server Update Run.dtsx"  /SERVER "(LocalDB)\v11.0" /Envreference 3
/Par "ServerID(Int16)";-1 
/Par "TargetServerConnectionString(String)";"\"Data Source=local(v11.0);Initial Catalog=master;Provider=SQLNCLI11.1;Auto Translate=False;Integrated Security=SSPI"\"
/Par "Disable1_1(Boolean)";False 
/Par "Disable1_2(Boolean)";False 
/Par "Disable2_1(Boolean)";False 
/Par "Disable2_2(Boolean)";False 
/Par "Disable2_3(Boolean)";False 
/Par "Disable2_4(Boolean)";False 
/Par "Disable2_5(Boolean)";False 
/Par "Disable2_6(Boolean)";False 
/Par "Disable2_7(Boolean)";False 
/Par "Disable2_8(Boolean)";False 
/Par "Disable2_9(Boolean)";False 
/Par "Disable2_10(Boolean)";False
/Par "Disable2_11(Boolean)";False
/Par "Disable2_12(Boolean)";False
/Par "Disable2_13(Boolean)";False
/Par "Disable2_14(Boolean)";False
/Par "Disable2_15(Boolean)";False
/Par "Disable3_1(Boolean)";False 
/Par "Disable3_2(Boolean)";False 
/Par "Disable3_3(Boolean)";False 
/Par "Disable4_1(Boolean)";False 
/Par "Disable4_2(Boolean)";False 
/Par "Disable4_3(Boolean)";False 
/Par "Disable5_1(Boolean)";False 
/Par "Disable5_2(Boolean)";False 
/Par "Disable5_3(Boolean)";False 
/Par "Disable6_1(Boolean)";False 
/Par "Disable6_2(Boolean)";False  

请注意,命令本身没有新行,我添加了新行以方便阅读。但是如果我将EXACT命令(直接来自调试)粘贴到dtexec [insert command here]中,它就会运行该项目。

有什么想法吗?

0 个答案:

没有答案