launching an executable application from a C# application

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
 
J

Jon Skeet [C# MVP]

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.
 
G

Guest

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
 
J

Jon Skeet [C# MVP]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top