1
Win32exception (0x80004005): The system cannot find the file specified in System.Diagnostics.Process.Startwithcreateprocess(Processstartinfo startInfo)
While trying to run a recently published program I came across this error, which refers to an application external to my application, called by the code snippet I mention below:
private void CreatePorts(string command, bool ports)
{
Process p = new Process();
p.StartInfo.WorkingDirectory = (Application.StartupPath + @"\com0com");
p.StartInfo.FileName = @"setupc.exe";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.LoadUserProfile = true;
p.StartInfo.Verb = @"runas";
p.StartInfo.CreateNoWindow = true;
p.StartInfo.Arguments = " " + command;
p.Start();
}
It is certain that the address passed to the parameter WorkingDirectory
is correct and that the file mentioned in the parameter FileName
exists, so I don’t understand what’s wrong.
Checking if the file exists and if you are allowed to run it?
– Leandro Angelo
@Leandroangelo is also not about permission, I set it to always open as an administrator. The file exists and has permissions.
– Caio de Paula Silva
But where in your code are you checking it?
– Leandro Angelo
As these are external executable applications, I believed that I would not need to check this internally, since I configured each application individually. But I check if my main application was opened with administrator permissions, in case.
– Caio de Paula Silva
And the
Application.StartupPath
, Have you checked if his path is returning what you expect? is not starting in within therelease
ordebug
, where you don’t have the subdirectorycom0com
?– Leandro Angelo
I checked yes. I just start after posting it. I’m pretty sure of the directory in which it is running.
– Caio de Paula Silva