electron关闭窗口打开批处理bat文件,electron打开本地文件

main.js

// 导入 shell 模块
const {app, BrowserWindow, shell} = require('electron')

// 在关闭的时候使用shell.openPath()函数打开当前目录的stop.bat批处理文件
app.on('window-all-closed', function () {
  // shell.openPath(path.resolve(__dirname, '.\\stop.bat'));
  shell.openPath(path.resolve() + '\\stop.bat');
  if (process.platform !== 'darwin') app.quit()
})

版权声明:本文为Vampire69原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。