D Sk

D Sk

  • NA
  • 9
  • 1k

calling another exe from my c#code

Jul 26 2017 4:15 AM
Hi all,
I have an exe MCP2210CLI placed at C:\Users\testuser\Desktop. I cannot run it directly by double clicking on it. So I use command prompt and execute the following.

C:\Users\testuser>cd desktop

C:\Users\testuser\Desktop>MCP2210CLI -devices

No devices connected.


I want to do these tasks in my c# code and generate the output in a command prompt.

I have written the following code. Howevwe an empty command prompt window opens. What change is needed in my code to get the exe running?

Process myProcess = new Process();

try
{

myProcess.StartInfo.FileName = @"C:\Users\testuser\Desktop\MCP2210CLI.exe";
myProcess.StartInfo.CreateNoWindow = true;
myProcess.StartInfo.Arguments = "-devices";
myProcess.Start();

myProcess.WaitForExit();

}
catch (Exception e)
{
Console.WriteLine("error",e.Message);
}


Thanks in advance.

Answers (1)