Last active
June 26, 2019 21:07
-
-
Save pwlin/9068069 to your computer and use it in GitHub Desktop.
nodejs open external program
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function testExternalApp(){ | |
////////////////////////////////// | |
// http://stackoverflow.com/questions/18183882/node-webkit-how-to-execute-an-exe-file | |
// https://github.com/rogerwang/node-webkit/wiki/Clipboard | |
var execFile = require('child_process').execFile, child; | |
child = execFile('C:\\Program Files\\Microsoft Office\\Office12\\winword.exe', function(error,stdout,stderr) { | |
if (error) { | |
//console.log(error.stack); | |
//console.log('Error code: '+ error.code); | |
//console.log('Signal received: '+ | |
// error.signal); | |
} | |
//console.log('Child Process stdout: '+ stdout); | |
//console.log('Child Process stderr: '+ stderr); | |
}); | |
child.on('exit', function (code) { | |
//console.log('Child process exited '+ | |
// 'with exit code '+ code); | |
//alert('exit'); | |
// Load native UI library | |
var gui = require('nw.gui'); | |
var clipboard = gui.Clipboard.get(); | |
var text = clipboard.get('text'); | |
alert(text); | |
}); | |
/////////////////////////////////// | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment