System.Diagnostics.Process.Start 
Author Message
 System.Diagnostics.Process.Start

I have a c application   myApp.exe , this application
return value for example 2020 .

in my C# application i run this application by the
following way :

System.Diagnostics.Process.Start("cmd /c myApp.exe ");

but this way don't give my the ability to get the return
value.
if this not currect how can i get the return value, or
which function can give me the ability to do that exactly
like the ( system("myApp.exe") ) function in C language .



Mon, 13 Dec 2004 23:24:23 GMT  
 System.Diagnostics.Process.Start

try this

 Process  p;

string s =  p.StandardOutput.ReadToEnd(); //or ReadLine()

int i =  Convert.ToInt32(s);

Quote:
>-----Original Message-----
>I have a c application   myApp.exe , this application
>return value for example 2020 .

>in my c# application i run this application by the
>following way :

>System.Diagnostics.Process.Start("cmd /c myApp.exe ");

>but this way don't give my the ability to get the return
>value.
>if this not currect how can i get the return value, or
>which function can give me the ability to do that exactly
>like the ( system("myApp.exe") ) function in C language .

>.



Mon, 13 Dec 2004 23:42:40 GMT  
 System.Diagnostics.Process.Start


Quote:
> I have a c application   myApp.exe , this application
> return value for example 2020 .

> in my c# application i run this application by the
> following way :

> System.Diagnostics.Process.Start("cmd /c myApp.exe ");

> but this way don't give my the ability to get the return
> value.
> if this not currect how can i get the return value, or
> which function can give me the ability to do that exactly
> like the ( system("myApp.exe") ) function in C language .

Why can't you just do: Process.Start("myApp.exe")?

-c



Mon, 13 Dec 2004 23:45:31 GMT  
 System.Diagnostics.Process.Start
Where in this code you are running the myApp.exe
aplication.
i didn't successful to used this code , Pleas give me more
information .
Thnx
Quote:
>-----Original Message-----

>try this

> Process  p;

>string s =  p.StandardOutput.ReadToEnd(); //or ReadLine()

>int i =  Convert.ToInt32(s);

>>-----Original Message-----
>>I have a c application   myApp.exe , this application
>>return value for example 2020 .

>>in my c# application i run this application by the
>>following way :

>>System.Diagnostics.Process.Start("cmd /c myApp.exe ");

>>but this way don't give my the ability to get the return
>>value.
>>if this not currect how can i get the return value, or
>>which function can give me the ability to do that
exactly
>>like the ( system("myApp.exe") ) function in C language .

>>.

>.



Tue, 14 Dec 2004 20:26:03 GMT  
 System.Diagnostics.Process.Start

I have a c application   myApp.exe , this application
return value for example 2020 .

in my c# application i run this application by the
following way :

System.Diagnostics.Process.Start("cmd /c myApp.exe ");

but this way don't give my the ability to get the return
value.
if this not currect how can i get the return value, or
which function can give me the ability to do that
exactly
like the ( system("myApp.exe") ) function in C language .



Fri, 17 Dec 2004 20:50:03 GMT  
 System.Diagnostics.Process.Start
Use other overload.

Process p=new Process();
p.StartInfo=new ProcessStartInfo("myprog.exe");
Process.Start();
Process.WaitForExit();
// Now use Process.ExitCode property..



Fri, 17 Dec 2004 21:03:04 GMT  
 System.Diagnostics.Process.Start
Hello,

You may use Process.ExitCode to get the return value. Here is a sample for
your reference:

Process p = Process.Start("myApp.exe");
p.WaitForExit();
MessageBox.Show(p.ExitCode.ToString());

Hope this helps.

Regards,
Max
==========================
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
|Content-Class: urn:content-classes:message


|Subject: System.Diagnostics.Process.Start
|
|I have a c application   myApp.exe , this application
|return value for example 2020 .
|
|in my c# application i run this application by the
|following way :
|
|System.Diagnostics.Process.Start("cmd /c myApp.exe ");
|
|but this way don't give my the ability to get the return
|value.
|if this not currect how can i get the return value, or
|which function can give me the ability to do that
|exactly
|like the ( system("myApp.exe") ) function in C language .
|
|
|
|
|
|
|



Sat, 18 Dec 2004 15:25:39 GMT  
 System.Diagnostics.Process.Start
this well stuck my application till the Exit occur, but i
want to kill the proccess afetr time out, but the
p.WaitForExit(3000);
not working currectly , Help me.

Yosi

Quote:
>-----Original Message-----
>Hello,

>You may use Process.ExitCode to get the return value.

Here is a sample for
Quote:
>your reference:

>Process p = Process.Start("myApp.exe");
>p.WaitForExit();
>MessageBox.Show(p.ExitCode.ToString());

>Hope this helps.

>Regards,
>Max
>==========================
>This posting is provided "AS IS" with no warranties, and
confers no rights.

>--------------------
>|Content-Class: urn:content-classes:message


>|Subject: System.Diagnostics.Process.Start
>|
>|I have a c application   myApp.exe , this application
>|return value for example 2020 .
>|
>|in my c# application i run this application by the
>|following way :
>|
>|System.Diagnostics.Process.Start("cmd /c myApp.exe ");
>|
>|but this way don't give my the ability to get the return
>|value.
>|if this not currect how can i get the return value, or
>|which function can give me the ability to do that
>|exactly
>|like the ( system("myApp.exe") ) function in C language .
>|
>|
>|
>|
>|
>|
>|

>.



Sun, 02 Jan 2005 15:39:13 GMT  
 System.Diagnostics.Process.Start
Hello,

Try the following code:

Process p = Process.Start("notepad.exe");
if (!p.WaitForExit(3000))
   p.Kill();
MessageBox.Show(p.ExitCode.ToString());

Hope this helps.

Regards,
Max
==========================
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
|Content-Class: urn:content-classes:message


|this well stuck my application till the Exit occur, but i
|want to kill the proccess afetr time out, but the
|p.WaitForExit(3000);
|not working currectly , Help me.
|
|Yosi
|
|

Quote:
|>-----Original Message-----
|>Hello,
|>
|>You may use Process.ExitCode to get the return value.
|Here is a sample for
|>your reference:
|>
|>Process p = Process.Start("myApp.exe");
|>p.WaitForExit();
|>MessageBox.Show(p.ExitCode.ToString());
|>
|>Hope this helps.
|>
|>Regards,
|>Max
|>==========================
|>This posting is provided "AS IS" with no warranties, and
|confers no rights.
|>
|>--------------------
|>|Content-Class: urn:content-classes:message


|>|Subject: System.Diagnostics.Process.Start
|>|
|>|I have a c application   myApp.exe , this application
|>|return value for example 2020 .
|>|
|>|in my c# application i run this application by the
|>|following way :
|>|
|>|System.Diagnostics.Process.Start("cmd /c myApp.exe ");
|>|
|>|but this way don't give my the ability to get the return
|>|value.
|>|if this not currect how can i get the return value, or
|>|which function can give me the ability to do that
|>|exactly
|>|like the ( system("myApp.exe") ) function in C language .
|>|
|>|
|>|
|>|
|>|
|>|
|>|
|>
|>.
|>
|



Mon, 03 Jan 2005 10:15:14 GMT  
 
 [ 9 post ] 

 Relevant Pages 

1. Capturing stdout using System.Diagnostics.Process.Start

2. Windows service applications (System.Diagnostics.DebuggableAttribute headaches)

3. Working with System.Diagnostics.Process

4. System.Diagnostics.Process, WaitForExit

5. Unhandled Exception: System.Configuration.ConfigurationException: Could not create System Configuration.NameValueSectionHandler, System

6. Executing Old 16 Bit DOS Apps from C# via System.Diagnostics.Process

7. System.Diagnostics.Process Questions

8. ? HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\Root\LEGACY_

9. System.Runtime.InteropServices.VTableCallsNotSupportedException

10. Diagnostics.Process.Start from Windows Service Question

11. Diagnostics.Process.Start from Windows Service Question

12. Can't Resolve System::Diagnostics::Debug

 

 
Powered by phpBB® Forum Software