在electron中,可以使用Node.js的child_process模块来结束系统上运行的进程。例如,结束系统上运行的名为ffmpeg.exe的进程,如下:
const { exec } = require('child_process');
function killFFmpegProcess() {
exec('taskkill /IM ffmpeg.exe /F', (error, stdout, stderr) => {
if (error) {
console.error(`执行的错误: ${error}`);
return;
}
console.log(`stdout: ${stdout}`);
console.error(`stderr: ${stderr}`);
});
}