Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

start process issue

I am using VSTS 2008 + C# + .Net 3.5 to develop a console application. And I want to start an external process (an exe file) from my C# application, and I want current C# application to be blocked until the external process stops and I also want to get the return code of the external process.

Any ideas how to implement this? Appreciate if some sample codes.

like image 762
George2 Avatar asked Mar 01 '10 07:03

George2


People also ask

What is start-process in PowerShell?

By default, Start-Process creates a new process that inherits all the environment variables that are defined in the current process. To specify the program that runs in the process, enter an executable file or script file, or a file that can be opened using a program on the computer.

How do I run a PowerShell script as administrator?

Use PowerShell in Administrative Mode If you need to run a PowerShell script as an administrator, you will need to open PowerShell in administrative mode. To do so, find PowerShell on the Start menu, right click on the PowerShell icon, and then select More | Run as Administrator from the shortcut menu.

How do I start a process in Windows?

While using the Command Prompt, follow these steps to quickly start or start a process in Windows 10. To start a process in Command Prompt: Open the Command Prompt window from the Start menu. In the cmd window, execute “start “C:\path\to\process.exe”“.


1 Answers

using (var process = Process.Start("test.exe"))
{
    process.WaitForExit();
    var exitCode = process.ExitCode;
}
like image 77
Darin Dimitrov Avatar answered Sep 21 '22 07:09

Darin Dimitrov