title: Electron exec launching multiple processes
body: <p>I'm creating an electron application that launches a .exe file. I use exec to do so, as it needs special arguments. In the renderer I have a button that launches it, If i click that button multiple times, it's going to execute the .exe file multiple times, so if i click it for the second time, it will launch 2 .exe files. This is my code in the renderer:</p>
  <pre><code>$(&quot;.buttonJSMain&quot;).click(function() {
      ipcRenderer.send(&quot;download-lc&quot;);
  
      ipcRenderer.on(&quot;downloaded-lc&quot;, (event) =&gt; {
          var authType = 'authType';
          var username = 'username';
          var password = 'password';
          var memory = 'memory';
  
          var arguments = authType + &quot; &quot; + username + &quot; &quot; + password + &quot; &quot; + memory;
          ipcRenderer.send('run', arguments);
      });
  })
  </code></pre>
  <p>This is my code in the main thread:</p>
  <pre><code>ipcMain.on('run', (event, arguments) =&gt; {
    var child = require('child_process').execFile;
    var args = arguments;
  
    try {
      exec(&quot;file.exe &quot; + arguments, (error, stdout, stderr);
    } catch {
      console.log('Couldn\'t start')
    }
  })
  </code></pre>
  <p>How could i make it so that it only launches the file one time?</p>