title: How to launch an executable in C# with specific guidelines
body: <p>Currently I'm porting a c++ exe launch to c#. I'm able to read through and understand the c++ code, but I'm struggling to find the c# equivalent. I believe that the original code launches the exe by utilizing the command prompt.</p>
  
  <p>I think it would be best to display the code that I am porting, so here it is:</p>
  
  <pre><code>  // This is basically running an exe to compile a file that I create
    short rtncod;
  
    int GPDataAge = FileAge(SelectedPath + GPDATA); //Checks age of GPDATA if it exists
  
    STARTUPINFO si;         // Startup information structure
    PROCESS_INFORMATION pi; // Process information structure
  
    memset(&amp;si, 0, sizeof(STARTUPINFO)); // Initializes STARTUPINFO to 0
    si.cb = sizeof(STARTUPINFO); // Set the size of STARTUPINFO struct
    AnsiString CmdLine = Config-&gt;ReadString("Configuration","CRTVSM","CRTVSM.EXE . -a"); // Windows version requires path
  
    rtncod = (short)CreateProcess(
                    NULL,   // pointer to name of executable module
                    CmdLine.c_str(), // pointer to command line string
                    NULL,   // pointer to process security attributes
                    NULL,   // pointer to thread security attributes
                    FALSE,   // handle inheritance flag
                    CREATE_NEW_CONSOLE, // creation flags
                    NULL,   // pointer to new environment block
                    NULL,   // pointer to current directory name
                    &amp;si,    // pointer to STARTUPINFO
                    &amp;pi);   // pointer to PROCESS_INFORMATION
    if (!rtncod) /*If rtncod was returned successful**/ {
      int LastError = GetLastError();
      if (LastError == 87 /* Lookup 87 error **/ &amp;&amp; AnsiString(SelectedPath + GPDATA).Length() &gt; 99)
        ShowMessage("CRTASM could not run due to extremely long path name.  Please map or move the folder to shorten the path");
      else
        ShowMessage("Could not compile VSMInfo.dat =&gt;" + IntToStr(LastError));
    }
    else /* If successful **/ {
      unsigned long ExitCode;
      // CartTools will 'lock up' while waiting for CRTASM
      do {
        rtncod = GetExitCodeProcess(pi.hProcess,&amp;ExitCode);
      } while (rtncod &amp;&amp; ExitCode == STILL_ACTIVE);
      if (rtncod == 0) {
        rtncod = GetLastError();
        ShowMessage("Could not watch CRTVSM compile VSMInfo.dat =&gt;" + IntToStr(GetLastError()));
      }
      CloseHandle(pi.hProcess);
      CloseHandle(pi.hThread);
    }
  
    if (GPDataAge == FileAge(SelectedPath + GPDATA)) // date/time didn't change!
      Application-&gt;MessageBox(AnsiString("Output blocking file (" + SelectedPath + GPDATA") failed to be updated.  Check operation of CRTVSM.EXE before using "GPDATA" with SAM/CMS!").c_str(),"CRTVSM Error",MB_OK|MB_ICONHAND);
  </code></pre>
  
  <p>All of this may not be relevant, and you may not know where my personal elements come from, but that is okay as I am only concerned with the MICROSOFT process elements (such as <code>CreateProcess</code> and <code>STARTUPINFO</code>).</p>
  
  <p>So far I have looked at the <code>Process.Start</code> method provided in <a href="https://stackoverflow.com/questions/240171/launching-a-application-exe-from-c">this question</a>, but do not think that it allows me to go through the same processes as the ones listed above. </p>
  
  <p><strong>My question is, what class or methods can I use to customize my exe launch in a equivalent manner to the launch that is performed in the c++ code above?</strong></p>
  
  <p><strong>UPDATE:</strong> Currently, I have the executable file located inside a folder that I created in the solution of my program. To launch the executable I am using the <a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo%28v=vs.110%29.aspx" rel="nofollow noreferrer"><code>ProcessStartInfo</code> class</a>.</p>
  
  <pre><code>//The folder that the exe is located in is called "Executables"
  ProcessStartInfo startInfo = new ProcessStartInfo("Executables\\MYEXECUTABLE.EXE");
  Process.Start(startInfo);
  </code></pre>
  
  <p>Whenever I run the above lines of code I get a <code>Win32Exception was unhandled</code>, and it says that "The system cannot find the file specified".</p>