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()
})

Guess you like

Origin blog.csdn.net/Vampire69/article/details/120226304