久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

從 Electron 主線程運行批處理文件

Run batch file from Electron main thread(從 Electron 主線程運行批處理文件)
本文介紹了從 Electron 主線程運行批處理文件的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在嘗試從我的電子應用程序中運行一個簡單的批處理文件.這是我的代碼:

I'm attempting to run a simple batch file from my electron application. Here is my code:

globalShortcut.register('Control+B', () => {
    log.info('Batch File Triggered: ' + app.getAppPath() + '\local\print.bat')
    require('child_process').exec(app.getAppPath() + '\local\print.bat', function (err, stdout, stderr) {
        if (err) {
            // Ooops.
            // console.log(stderr);
            return console.log(err);
        }

        // Done.
        console.log(stdout);
    });
})

當用戶按下 Control+B 時應該會觸發批處理文件,但它不起作用.生成了日志條目,并且我驗證了路徑是正確的,但該文件從未真正啟動過.

The batch file should be triggered when Control+B is pressed by the user, but it does not work. The log entry is made, and I've verified the path is correct, but the file is never actually launched.

我發現了這些問題,它們提出了同樣的問題,但這些問題已經 4 歲了,沒有一個答案對我有用,沒有顯示,沒有錯誤,什么都沒有.

I found these questions, which ask the same question, but these are 4 years old at this point and none of the answers have worked for me, there is no display, no error, nothing.

  • 從node.js運行一個windows批處理文件
  • http://stackoverflow.com/questions/21557461/execute-a-batch-file-from-nodejs

我也嘗試過 child_process.spawn,但也沒有什么明顯的效果.

I've also tried the child_process.spawn but that also did nothing noticeable.

var ls = spawn('cmd.exe', ['/c', app.getAppPath() + '\local\print.bat']);

如何從電子應用程序中啟動批處理文件?

How can I launch my batch file from my electron application?

推薦答案

我剛剛發現了一個如此簡單的方法來做到這一點.您可以使用電子外殼模塊,如下所示:

I've just discovered such an easy way to do this. You can use the electron shell module, like this:

const {shell} = require('electron');
// Open a local file in the default app
shell.openItem(app.getAppPath() + '\local\print.bat');

這篇關于從 Electron 主線程運行批處理文件的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to fix BrowserWindow is not a constructor error when creating child window in Electron renderer process(在 Electron 渲染器進程中創建子窗口時如何修復 BrowserWindow 不是構造函數錯誤) - IT屋-程序員軟件開發技術
mainWindow.loadURL(quot;https://localhost:3000/quot;) show white screen on Electron app(mainWindow.loadURL(https://localhost:3000/) 在 Electron 應用程序上顯示白屏)
Electron webContents executeJavaScript : Cannot execute script on second on loadURL(Electron webContents executeJavaScript:無法在第二個 loadURL 上執行腳本)
how to use electron browser window inside components in angular-cli?(如何在angular-cli的組件內使用電子瀏覽器窗口?)
ElectronJS - sharing redux store between windows?(ElectronJS - 在 Windows 之間共享 redux 存儲?)
How to access camera/webcamera inside electron app?(如何在電子應用程序中訪問相機/網絡攝像頭?)
主站蜘蛛池模板: 国产精品久久久久久久久久三级 | 在线观看av网站 | 国产一区二区激情视频 | 国产一区二区在线免费视频 | 日本成人片在线观看 | 亚洲午夜网 | 国产欧美一区二区精品忘忧草 | 亚洲一区二区三区在线 | 日韩精品在线观看视频 | 久久久久久久久久久久久9999 | 91精品国产91久久综合桃花 | 国产丝袜一区二区三区免费视频 | www国产成人免费观看视频,深夜成人网 | 久久久久久久久久久久久久av | 美女网站视频免费黄 | 亚洲欧美日韩成人在线 | 久久黄色网 | 精品久久久久久亚洲精品 | 亚洲日本一区二区三区四区 | 精品视频国产 | 成人高清网站 | 国产精品免费一区二区三区四区 | 老司机成人在线 | 成人小视频在线观看 | 免费精品在线视频 | 日韩在线免费看 | 欧美一区二区三区 | 国产精品久久 | 欧美另类视频在线 | 蜜臀久久99精品久久久久野外 | 国产一区二区在线视频 | 中文字幕在线观看成人 | 日日夜夜精品免费视频 | 国产精品成人国产乱 | 日韩欧美在线视频播放 | 国产精品一区在线观看你懂的 | 亚洲视频免费 | 久久久性色精品国产免费观看 | 亚洲综合大片69999 | 91精品国产一区二区三区 | 国产精品一区二区在线 |