coreybutler / node-windows

Windows support for Node.JS scripts (daemons, eventlog, UAC, etc).
Other
2.79k stars 358 forks source link

Cant execute GUI process #226

Closed 50l3r closed 5 years ago

50l3r commented 5 years ago

I create a service like this:

var Service = require('node-windows').Service;

// Create a new service object
var svc = new Service({
  name:'50l3r Realm',
  description: 'Domotik automation for 50l3r Realm.',
  script: require('path').join(__dirname,'server.js')
});

// Listen for the "install" event, which indicates the
// process is available as a service.
svc.on('install',function(){
  svc.start();
});

svc.install();

And modify desktop interaction to the server

But process only execute in background. Process named Hyperspin.exe:

This is my code:

var options = { cwd: 'C:\Hyperspin\' };

var options = { cwd: 'C:\\Hyperspin\\' };

nrc.run('C:\\Hyperspin\\Hyperspin.exe', options).then(function(exitCodes) {
    console.log("[INFO] Ejecutando HyperSpin")
}, function(err) {
    console.log('Ocurrio un error al ejecutar HS: ', err);
});
coreybutler commented 5 years ago

Please see the wiki, specifically https://github.com/coreybutler/node-windows/wiki#my-script-runs-fine-on-its-own-but-not-with-node-windows-why.

I'm fairly certain the issue is script: require('path').join(__dirname,'server.js').

You most likely want script: require('path').join(proccess.cwd(),'server.js') instead.

50l3r commented 5 years ago

Please see the wiki, specifically https://github.com/coreybutler/node-windows/wiki#my-script-runs-fine-on-its-own-but-not-with-node-windows-why.

I'm fairly certain the issue is script: require('path').join(__dirname,'server.js').

You most likely want script: require('path').join(proccess.cwd(),'server.js') instead.

Same problem. Process execute in background:

coreybutler commented 5 years ago

Apologies, I misunderstood your original issue (even though you were clear in your writing).

Since the process is running, node-windows is working. Remember, node-windows is designed for running background processes. It will not launch a GUI. If you want to do this, it's possible, but you'd need to write some code in your app to launch the GUI. That's outside the scope of what node-windows does, but I'm pretty sure you can find help if you Google "launching GUI from Node.js".

Closing since this appears to be an application issue, not a node-windows issue.