title: How to execute an external program in c
body: <p>I want to start a .exe program that is in my computer after a run my code and still do some stuff after the program opens but I'm stuck in how to open it.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;time.h&gt;
  //#define _WIN32_WINNT 0x0500
  #include &lt;windows.h&gt;
  
  int main () {
     POINT mouse;
     //HWND hWnd = GetConsoleWindow();
     //ShowWindow(hWnd, SW_MINIMIZE); 
     //ShowWindow(hWnd, SW_HIDE);
     // how to open program ?
     system("start C:\Riot Games\League of Legends\LeagueClient.exe");
  
     while (true) {
        GetCursorPos(&amp;mouse);
        int x = mouse.x;
        int y = mouse.y;
        SetCursorPos(x + rand() % 40 - 20, y + rand() % 40 - 20);
        printf("x = %d ", mouse.x);
        printf("y = %d\n", mouse.y);
        Sleep(1);
     }
  }
  </code></pre>
  
  <p>The system function doesn't work for me for two reasons; it pauses the code until the app is exit, and when I try to run the code it says he can't find C:Riot. </p>