Matt Altman

Matt Altman

  • NA
  • 3
  • 2.4k

Redirect process output

May 24 2011 12:22 PM
Hey all,

I am working on a project that will query scheduled tasks running on other systems. I have written a console application that runs schtasks and redirects the output to a text file. However, I was wondering if it is possible to redirect this output to a SQL database?

I was thinking of writing a stored procedure which will handle all of the inserts but I don't know what to do with the data inside the console app. I already have a stored proc that redirects XML data to a database but I am trying not to have files laying around every where.

Any input would be great. Here is my code in case anyone wants to see it:

Process process = new Process();
process.StartInfo.FileName = "C:\\Windows\\System32\\schtasks.exe";
process.StartInfo.Arguments = "/query /s 192.168.0.124";
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.Start();


string procOutput = process.StandardOutput.ReadToEnd();

Below here is just the redirection to a text file using a text writer.

Answers (1)