processStartInfo in C#

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

cu.4m.srinivas

Hi all,

I want to get the process running in the 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
anyInvalidOperationException).

when i try to print the parameters other than that of StartInfo's, its
working fine; only in case of StartInfo params like FileName and
Arguments, it's returning "null".


Can anyone help me out in this ???
 
it should not compile according to the posting..
a is not defined.. is a mean a=args??
if yes..
then I guess the startinfo reset once the process is started you may find
this value by some other property like MainWindowTitle

Nirosh.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top