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.
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.
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.
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”“.
using (var process = Process.Start("test.exe"))
{
process.WaitForExit();
var exitCode = process.ExitCode;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With