I've tried to execute
*.exe
exec error: { Error: spawn ${__dirname}/install.exe ENOENT
var execFile = require('child_process').execFile
execFile('${__dirname}/install.exe', function(error, stderr) {
console.log('stderr: ', __dirname);
if (error !== null) {
console.log('exec error: ', error);
}
});
'${__dirname}\install.exe'
'./install.exe'
'D:\install.exe'
@FelixKling has the right advice; variables don't work unless you create your string with back-ticks. Additionally, it's a good idea to use the path
module to resolve file paths:
var path = require('path');
var execFile = require('child_process').execFile;
var exePath = path.resolve(__dirname, './install.exe');
execFile(exePath, function(error, stderr) {
console.log('stderr: ', __dirname);
if (error !== null) {
console.log('exec error: ', error);
}
});
Edit:
This is for your original question, about ENOENT
; for your second about UNKNOWN
errors, the cause can vary. It sounds like it might be a permissions issue since the executable needs to elevate to administrator permissions.