launching an executable application from a C# application

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to launch an executable application from my C# application. I
tried using the Process class which did start the application but it did not
show the command prompt window.
My code is as follows:
Process p = Process.Start(@"C:\Debug\MyApp.exe");
This code replaces my C++ code which was the following:
ShellExecut(NULL,"open","C:\\Debug\\MyApp.exe",NULL,NULL,SW_SHOWNORMAL);

So how can I get the command prompt window showing up when the application
is launched?

Thanks
 
rgarf said:
I am trying to launch an executable application from my C# application. I
tried using the Process class which did start the application but it did not
show the command prompt window.
My code is as follows:
Process p = Process.Start(@"C:\Debug\MyApp.exe");
This code replaces my C++ code which was the following:
ShellExecut(NULL,"open","C:\\Debug\\MyApp.exe",NULL,NULL,SW_SHOWNORMAL);

So how can I get the command prompt window showing up when the application
is launched?

Use a ProcessStartInfo and set UseShellExecute to true.
 
Thanks for the reply, I tried that and still did not get the command prompt
window showing, I can see that the .exe is running from the task manager, but
no command prompt window shows.
I changed my code to do the following:

ProcessStartInfo pInfo = new ProcessStartInfo();
pInfo.FileName = "C:\Debug\MyApp.exe";
pInfo.UseShellExecute = true;
Process p = Process.Start(pInfo);

So what else do I have to do to get the window showing?

Thanks
 
rgarf said:
Thanks for the reply, I tried that and still did not get the command prompt
window showing, I can see that the .exe is running from the task manager, but
no command prompt window shows.
I changed my code to do the following:

ProcessStartInfo pInfo = new ProcessStartInfo();
pInfo.FileName = "C:\Debug\MyApp.exe";
pInfo.UseShellExecute = true;
Process p = Process.Start(pInfo);

So what else do I have to do to get the window showing?

Hmm... if that doesn't work, then it's probably easiest just to
actually execute cmd yourself, with an appropriate parameter to launch
the executable.
 
Back
Top