CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2009
    Posts
    1

    Process.Start, write to file

    Author: Carissa

    I am trying to use Process.Start to run a command that opens SQLPlus, runs a query, and puts the output in a file. (There are reasons I can't use a batch file).


    Right now it works, except the results are written in the new command window it opens to run sqlplus. So I've been trying to write the results to a file, or for now at least to the console.

    System.Diagnostics.Process p = new System.Diagnostics.Process();
    p.StartInfo.FileName = db_startsql;
    p.StartInfo.RedirectStandardOutput = true;
    p.StartInfo.UseShellExecute = false;
    p.StartInfo.Arguments = info;
    p.Start();
    Console.WriteLine("done with start");
    p.WaitForExit();
    Console.WriteLine("Done waiting for exit");
    string output = p.StandardOutput.ReadToEnd();
    Console.Write(output);

    It gets to "done with start", and then hangs.

    If I output db_startsql+info, and put that in a command line it works, so that's not the problem. Help?

  2. #2
    Join Date
    Jun 2008
    Posts
    2,477

    Re: Process.Start, write to file

    Well, it looks like your external app is not exiting. It's hard to help without seeing the code behind that program.

  3. #3
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Process.Start, write to file

    Please show what are contained within the db_startsql and info variables.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured