Question

I am trying to run a process with System.Diagnostics.Process.Start(), but am getting the following error:

System.ComponentModel.Win32Exception: The system cannot find the file specified

I double checked the path, and even copied the string to a cmd window, where it ran just fine. What could be the problem?

I am using Win7 64 bit, the program I am trying to run was compiled with mingw64-x64, and I am compiling for .NET 2.0

EDIT
While trying to do the suggested

if (File.Exists(Your EXE)) {
}

I found that removing the flags from the command string solved the problem (I didn't think this was an issue and so didn't mention it before)

How do I run commands with parameters?

Was it helpful?

Solution

For arguments use this method. Or overload with ProcessStartInfo.

OTHER TIPS

Windows 7 folder redirection could be the issue.

Basically sometimes when you try to access "C:\program files" it will redirect you to something like "C:\users\username\program files"

I'm looking up some resources for you. I'll let you know when I find something that explains it better than I can.

EDIT:

I find that commands with parameters are a pain in the butt to get working correctly. I usually just resort to writing a batch file and then have C# run that.

Add an if statement like:

if (File.Exists(Your EXE))
{
    // Start the process
} 

Otherwise you can not make sure the Path used is the right one.

Take a look at this answer too, maby it helps

Use the ProcessStartInfo class and set values to the Arguments property:

http://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.aspx

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top