none
SSIS Script Task calling batch file does not return to run the next task in a Package

    Question

  • Hello!

    I have a series of Tasks running in an SSIS Package. Everything runs perfectly in debug mode, however when I run without debug it hangs after a Script Task when I am calling a batch file (as if it doesn't return). Here is my code. I am almost close to deploying this if I can get it to work. The batch files runs fine but doesn't return to run the next Task.  Thanks! Mike

       public void Main()
            {
                Program myProcess = new Program();

                myProcess.OpenWithArguments();

            }
            class Program
            {

                // TODO: Add your code here
                public void OpenWithArguments()
                {

                    string command = @"C:\p260Batch\frodobattest.bat";
                    ProcessStartInfo startInfo = new ProcessStartInfo("CMD.exe", "/k " + command)
            
                    Process p = new Process();

                    startInfo.RedirectStandardInput = true;

                    startInfo.UseShellExecute = false; //changed from false on 5/6
                    startInfo.Verb = "runas";

                    startInfo.RedirectStandardOutput = true;

                    startInfo.RedirectStandardError = true;

                    p = Process.Start(startInfo);

                    p.WaitForExit();

                    p.StandardInput.WriteLine(@"EXIT");

                    p.StandardInput.Close();

                    p.WaitForExit();

                    p.Close();

                    Console.Read();


                }


    Mike Kiser

    Tuesday, July 09, 2013 9:17 PM

Answers

  • Isnt this the expected behavior, the statement is waiting for the control to return back from execution. 

    p.WaitForExit(); 

    Also did you try removing the last line console.read once you are executing from the .bat file? 


    Abhinav http://bishtabhinav.wordpress.com/

    Tuesday, July 09, 2013 10:12 PM

All replies

  • Isnt this the expected behavior, the statement is waiting for the control to return back from execution. 

    p.WaitForExit(); 

    Also did you try removing the last line console.read once you are executing from the .bat file? 


    Abhinav http://bishtabhinav.wordpress.com/

    Tuesday, July 09, 2013 10:12 PM
  • Great Point! The console.read was doing it. I guess it was waiting for a console that would never appear

    Mike Kiser

    Thursday, July 11, 2013 4:15 PM