I have an existing exe file (processStuff.exe) (it is written in c, in case that is relevant). From a command prompt in Windows I can run:
processStuff.exe -f myDataFile
This will run processStuff.exe which will go on to load the data in the file called myDataFile. That all works fine.
I need to do this programmatically from my Electron app.
So, I add this to my code in my Electron source file:
var spawnFile = require('child_process').execFile;
and I make the call like so:
var executablePath = ''+process.env.SYS_HOME + "\\myFolder\\processStuff.exe";
if(fs.existsSync(executablePath))
{
var opt = function()
{
spawnFile(executablePath, ["-f", "myDataFile"], function(err:any, data:any) {
err = err;
data = data;
console.log(err)
console.log(data.toString());
});
}
opt()
}
The exe IS run, but the file is not loaded. So somehow my call to spawnFile is not identical to me running processStuff.exe -f myDataFile from the command console.
Can anyone help me to get this to work? Thanks.