質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Electron

Electronは、HTML5とNode.jsというWebの技術を用いてデスクトップアプリケーションを作成できるクロスプラットフォームな実行環境です。

Node.js

Node.jsとはGoogleのV8 JavaScriptエンジンを使用しているサーバーサイドのイベント駆動型プログラムです。

JavaScript

JavaScriptは、プログラミング言語のひとつです。ネットスケープコミュニケーションズで開発されました。 開発当初はLiveScriptと呼ばれていましたが、業務提携していたサン・マイクロシステムズが開発したJavaが脚光を浴びていたことから、JavaScriptと改名されました。 動きのあるWebページを作ることを目的に開発されたもので、主要なWebブラウザのほとんどに搭載されています。

Q&A

0回答

1798閲覧

javascript exeの利用

REIA

総合スコア26

Electron

Electronは、HTML5とNode.jsというWebの技術を用いてデスクトップアプリケーションを作成できるクロスプラットフォームな実行環境です。

Node.js

Node.jsとはGoogleのV8 JavaScriptエンジンを使用しているサーバーサイドのイベント駆動型プログラムです。

JavaScript

JavaScriptは、プログラミング言語のひとつです。ネットスケープコミュニケーションズで開発されました。 開発当初はLiveScriptと呼ばれていましたが、業務提携していたサン・マイクロシステムズが開発したJavaが脚光を浴びていたことから、JavaScriptと改名されました。 動きのあるWebページを作ることを目的に開発されたもので、主要なWebブラウザのほとんどに搭載されています。

0グッド

1クリップ

投稿2019/01/21 03:50

編集2019/01/24 00:47

electronでクライアントアプリを作成してその中でexeファイルを実行したいのですが、main.jsのカレントディレクトリに実行するexeが入っているにも関わらずopenできないエラーにあっています。
またデザイン面以外のjavascriptはwindowを作るmain.jsに記述するのが正しいのかも分かりません。
以下がコードになります。

javascript

1const {app, Menu, BrowserWindow} = require('electron'); 2const {exec, execFile} = require('child-process-promise'); 3const kill=require('tree-kill'); 4const APP_NAME = new Array('./src/test.exe'); 5let pid =new Array(); 6let mainWindow; 7let i =0; 8 9function createWindow(){ 10 mainWindow = new BrowserWindow({width:400,height:600,'icon': __dirname+'/src/REIAcat.ico',}); 11 mainWindow.loadFile("./index.html"); 12 Menu.setApplicationMenu(null); 13 if(process.env.NODE_EV=="debug") 14 mainWindow.webContents.openDevTools(); 15 mainWindow.on("closed",function(){ 16 mainWindow=null; 17 }); 18} 19app.on("ready",function(){ 20 //window逕滓・ 21 createWindow(); 22 //socket繧「繝励Μ襍キ蜍・ 23 // while(i < APP_NAME.length){ 24 execFile('open',[APP_NAME[i]]) 25 .then(_=>`powershell -command "Get-WmiObject win32_process | select processid, name | Where-Object {$_.name -match \"${APP_NAME[i]}\"} | select processid >> temp.txt ; (Get-Content \"temp.txt\")[3] ; del temp.txt"`) 26 .then((result)=>{ 27 if(result.stderr){ 28 throw(result.stderr); 29 } 30 pid.push(parseInt(result.stdout)); 31 logger.debug(`START AppName ${APP_NAME[i]},pid:${pid[i]}`); 32 i++; 33 34 }).catch((err)=>{ 35 logger.debug(`Error:${JSON.stringify(err)}`); 36 }); 37 38 // exec.then=then(function(){ 39 // exec(`powershell -command "Get-WmiObject win32_process | select processid, name | Where-Object {$_.name -match \"${APP_NAME[i]}\"} | select processid >> temp.txt ; (Get-Content \"temp.txt\")[3] ; del temp.txt"`, 40 // function(err,stdout,stderr){ 41 // if(err){ 42 // throw err; 43 // } 44 // }); 45 // }); 46 47 48 // } 49 50}); 51app.on("window-all-closed",function(){ 52 if(process.platform !== 'darwin'){ 53 i=0; 54 while(i <pid.length){ 55 kill(pid[i]); 56 i++; 57 } 58 app.quit() 59 } 60}); 61app.on("activate",function(){ 62 if(mainWindow===null) 63 createWindow(); 64 65});

child-promiseで起動してコマンドを使ってpidを取得しcloseWindowするときにkillするだけなのですが、
なぜかopenしてくれないという状況になっています。
わかる方がいれば教えていただけるとありがたいです。
回答よろしくお願いします。
エラー内容:

error

1{ ChildProcessError: spawn open ENOENT `open ./src/test.exe` (exited with error code ENOENT) 2 at callback (C:\Users\userName\Downloads\learn_c\socket\node_modules\child-process-promise\lib\index.js:33:27) 3at exithandler (child_process.js:306:5) 4at ChildProcess.errorhandler (child_process.js:318:5) 5at ChildProcess.emit (events.js:182:13) 6at Process.ChildProcess._handle.onexit (internal/child_process.js:238:12) 7at onErrorNT (internal/child_process.js:407:16) 8at process._tickCallback (internal/process/next_tick.js:63:19) 9 name: 'ChildProcessError', code: 'ENOENT', childProcess: { ChildProcess: { [Function: ChildProcess] super_: [Function] }, 10fork: [Function: fork], 11 _forkChild: [Function: _forkChild], 12 exec: { [Function] [Symbol(util.promisify.custom)]: [Function] }, 13 execFile: { [Function] [Symbol(util.promisify.custom)]: [Function] }, 14 spawn: [Function: spawn], 15 spawnSync: [Function: spawnSync], 16 execFileSync: [Function], 17execSync: [Function] }, 18stdout: '', 19 stderr: '' } 20

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

m.ts10806

2019/01/21 04:14

>openできないエラーにあっています。 基本的にはエラー文は要約せずにそのままご提示ください
REIA

2019/01/21 04:35

{ ChildProcessError: spawn open ENOENT `open ./src/test.exe` (exited with error code ENOENT) at callback (C:\Users\a1814\Downloads\learn_c\socket\node_modules\child-process-promise\lib\index.js:33:27) at exithandler (child_process.js:306:5) at ChildProcess.errorhandler (child_process.js:318:5) at ChildProcess.emit (events.js:182:13) at Process.ChildProcess._handle.onexit (internal/child_process.js:238:12) at onErrorNT (internal/child_process.js:407:16) at process._tickCallback (internal/process/next_tick.js:63:19) name: 'ChildProcessError', code: 'ENOENT', childProcess: { ChildProcess: { [Function: ChildProcess] super_: [Function] }, fork: [Function: fork], _forkChild: [Function: _forkChild], exec: { [Function] [Symbol(util.promisify.custom)]: [Function] }, execFile: { [Function] [Symbol(util.promisify.custom)]: [Function] }, spawn: [Function: spawn], spawnSync: [Function: spawnSync], execFileSync: [Function], execSync: [Function] }, stdout: '', stderr: '' } loggerが参照できないといわれたのでconsole.log(err);したところ上記のようなエラーが出ましたENOENTというエラー自体ほかの言語でも見たことがなく戸惑ってます。
m.ts10806

2019/01/21 04:38

質問は編集できるので質問本文へ追記してください(エラーもコードと同じくマークダウンのcode機能を利用してください)
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問