0

I'm writing an application that runs DTExec as another user to run an SSIS package that has been deployed to a server. Currently, I generate the argument string based on whether or not certain components are enabled.

Here's my issue... When running DTExec, I use the following code:

        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();

When I run this code, I receive the error "the stub received bad data" and the program crashes. When I go into debug mode, I can copy the string received as commands, then run command prompt as user hello123 and type dtexec [paste commands here] and it runs no problems at all. This leads me to believe that the command is sound. Below is the command variables contents:

/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  

Please note that there are no new lines in the command itself, I have added the newlines for ease of reading. But if I copy paste that EXACT command (directly from debugging) into dtexec [insert command here], it runs the project.

Any ideas?

Aserian
  • 1,047
  • 1
  • 15
  • 31
  • Do you set the working directory property? See [this MSDN link](https://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.password(v=vs.110).aspx) – Ron Beyer Nov 30 '15 at 19:50
  • @RonBeyer Hey, thank you for your reply. I had not set it, but I just attempted to set it and it did not fix the issue. – Aserian Nov 30 '15 at 21:15

0 Answers0