Error: The system can not find the specified file [C #]

0
  

Win32Exception (0x80004005):               The system can not find the file specified in System.Diagnostics.Process.StartWithCreateProcess (ProcessStartInfo startInfo)

When trying to run a newly published program I came across this error, which refers to an external application 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 do not understand what is wrong.

    
asked by anonymous 15.10.2018 / 16:24

1 answer

2

The solution was to create an environment variable for the process I've been trying to run. In my case: C:\Program Files (x86)\com0com

System → Config. Add to the variable in question     

16.10.2018 / 13:56