By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,058 Members | 1,209 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,058 IT Pros & Developers. It's quick & easy.

screen scraping dos application

P: 1
Hi All,

Can somebody maybe please help me?

- how do i screen scrape data from a dos application / window to .net application by using c#?
- how do i screen scrape data from a dos application / window to sql database?
- how do i screen scrape data from a dos application / window to sql database and insert other data back to the dos application / window?

Thanks
Dec 23 '09 #1
Share this Question
Share on Google+
1 Reply


100+
P: 270
Dear,
Hear's function for doing the task,

executes the command using cmd and returns the output as text

Expand|Select|Wrap|Line Numbers
  1. public String ExecuteCommandSync(object command)
  2.         {
  3.             try
  4.             {
  5.                 // create the ProcessStartInfo using "cmd" as the program to be run, and "/c " as the parameters.
  6.                 // Incidentally, /c tells cmd that we want it to execute the command that follows, and then exit.
  7.                 System.Diagnostics.ProcessStartInfo procStartInfo = new System.Diagnostics.ProcessStartInfo("cmd", "/c " + command);
  8.                 // The following commands are needed to redirect the standard output. 
  9.                 //This means that it will be redirected to the Process.StandardOutput StreamReader.
  10.                 procStartInfo.RedirectStandardOutput = true;
  11.                 procStartInfo.UseShellExecute = false;
  12.                 // Do not create the black window.
  13.                 procStartInfo.CreateNoWindow = true;
  14.                 // Now we create a process, assign its ProcessStartInfo and start it
  15.                 System.Diagnostics.Process proc = new System.Diagnostics.Process();
  16.                 proc.StartInfo = procStartInfo;
  17.                 proc.Start();
  18.  
  19.                 // Get the output into a string
  20.                 string result = proc.StandardOutput.ReadToEnd();
  21.  
  22.                 // Display the command output.
  23.                 return result;
  24.             }
  25.             catch(Exception ex)
  26.             {
  27.                 // Log the exception
  28.                 //return "";
  29.                 throw ex;
  30.             }
  31.         }
  32.  
Dec 23 '09 #2

Post your reply

Sign in to post your reply or Sign up for a free account.