0

我正在编写一个以另一个用户身份运行 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 [在此处插入命令],它将运行该项目。

有任何想法吗?

4

0 回答 0