Process.Start

G

Guest

I am using C#. I have a windows form with a button on it. When clicked, I want to run an application. I am using the ProcessStartInfo class and the Process.Start method. The .exe I am trying to run throws me a bunch of error messages when I try and start it using Process.Start. Here is the code

System.Environment.CurrentDirectory = node.Attributes["path"].Value; // (thought this may help, but didn't
ProcessStartInfo pi = new ProcessStartInfo()
pi.UseShellExecute = true
pi.FileName = ((Button)sender).Name; //Contains the .exe string (this is working correctly
pi.WorkingDirectory = node.Attributes["path"].Value; // (thought this may help, but didn't
pi.WindowStyle = ProcessWindowStyle.Maximized; // (tried with and without this line
Process p = Process.Start(pi)
p.WaitForExit(); // Again, tried with/without this (although I assume this shouldn't matter

Anyhoo - as you can see, there isn't anything fancy that I am trying to accomplish. All of my variables have been checked and they are returning exactly as expected - so it's something with the System.Diagnostics.Process and StartInfo class that is preventing my application from running properly

The .exe runs fine when I run it from Explorer. Is there another way to start an external program in my windows application besides Process.Start

I'm guessing it's a path issue, but I'm stumped at this point. Anyone? :)

Thanks much for the help, :
Rob
 
S

Stevo

Rob,

Can you run a basic app like notepad using the same code? I copied and
pasted your code and used the notepad path (worked fine), and then a dot net
application path, and that worked fine also.

Laggin said:
I am using C#. I have a windows form with a button on it. When clicked,
I want to run an application. I am using the ProcessStartInfo class and the
Process.Start method. The .exe I am trying to run throws me a bunch of
error messages when I try and start it using Process.Start. Here is the
code:
System.Environment.CurrentDirectory = node.Attributes["path"].Value; //
(thought this may help, but didn't)
ProcessStartInfo pi = new ProcessStartInfo();
pi.UseShellExecute = true;
pi.FileName = ((Button)sender).Name; //Contains the .exe string (this is working correctly)
pi.WorkingDirectory = node.Attributes["path"].Value; // (thought this may help, but didn't)
pi.WindowStyle = ProcessWindowStyle.Maximized; // (tried with and without this line)
Process p = Process.Start(pi);
p.WaitForExit(); // Again, tried with/without this (although I assume this shouldn't matter)

Anyhoo - as you can see, there isn't anything fancy that I am trying to
accomplish. All of my variables have been checked and they are returning
exactly as expected - so it's something with the System.Diagnostics.Process
and StartInfo class that is preventing my application from running properly.
The .exe runs fine when I run it from Explorer. Is there another way to
start an external program in my windows application besides Process.Start?
 

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