pStartInfo in C#.Net

  • Thread starter Thread starter cu.4m.srinivas
  • Start date Start date
C

cu.4m.srinivas

Hi all,

I want to do the foll.

I want to get the process running in the name system, with name "abc",
and in turn get their arguments, so that i do some processing later

Foll. is my code:
Process proc = new Process();
proc.StartInfo.FileName = "notepad.exe";
proc.StartInfo.Arguments = "abc.cs";
proc.StartInfo.UseShellExecute = false;
proc.Start();

Process[] p = Process.GetProcessesByName("notepad");
string args = p[0].StartInfo.Arguments.ToString();
Console.WriteLine("args: " + a); //this is retning null - shd retn
abc.cs

string b = p[0].BasePriority.ToString();
Console.WriteLine("BASE PRIORITY: "+ b); //this comes out correctly


With the above code, args is returnin a null string. (Also abc is
currently running-obvious 'coz i didnt get any
InvalidOperationException). when i try to print the parameters other
than that of StartInfo, its working fine-only in case of StartInfo
params.
 
Hi,

There is not much AdoNet in your question. A more proper newsgroup is than
microsoft.dotnet.languages.csharp for your question.

You will than get answers as

\\\
Process p = new Process();
ProcessStartInfo pi = new ProcessStartInfo();
pi.UseShellExecute = false;
pi.RedirectStandardOutput = true;
pi.Arguments = "www.google.com";
pi.WorkingDirectory = "C:\\windows\\system32";
//this for nt* computers
pi.FileName = "ping";
p.StartInfo = pi;
p.Start();
System.IO.StreamReader sr = p.StandardOutput;
System.Text.StringBuilder sb = new System.Text.StringBuilder("");
int input = sr.Read();
while (input != -1)
{
sb.Append((char) input);
input = sr.Read();
}
MessageBox.Show(sb.ToString());
///

I hope this helps,

Cor
 
Back
Top