coreybutler / node-windows

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

Child process error #163

Open furyscript opened 7 years ago

furyscript commented 7 years ago

Hi,

We have made a node-windows service that have a main script that run a child process command to open an .exe like this

var cp = require("child_process");
cp.exec("C:\\Users\\test\\Desktop\\file.exe", function(error, stdout) {
});

If we run node main.js it's work like expected, but if we run service it throw error Command failed I don't know why.. Any idea?

jdziat commented 7 years ago

First thoughts are permissions. Try changing the user running the service to one that has permissions to that directory.

via Newton Mail [https://cloudmagic.com/k/d/mailapp?ct=pi&cv=9.4.52&pv=10.2.1&source=email_footer_2] On Thu, Mar 2, 2017 at 3:34 PM, Daviz notifications@github.com wrote: Hi,

We have made a node-windows service that have a main script that run a child process command to open an .exe like this

var cp = require("child_process"); cp.exec("C:\Users\test\Desktop\file.exe", function(error, stdout) { });

If we run node main.js it's work like expected, but if we run service it throw error Command failed I don't know why.. Any idea?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub [https://github.com/coreybutler/node-windows/issues/163] , or mute the thread [https://github.com/notifications/unsubscribe-auth/ABIType7hfoGWRwRFxgfbexEXvdJ98wAks5rhyfGgaJpZM4MRflw] .

furyscript commented 7 years ago

Thanks for ask me, but I've try a lot also with elevate and nothing change. The user is administrator and file doesn't have UAC...

coreybutler commented 7 years ago

Remember that running the node-windows service as an elevated user doesn't mean the child process is running as an elevated admin user. You have to explicitly elevate permissions for the child process... it's not enough to just run the parent process as an elevated admin. This means you may need to change the command in in cp.exec.

coreybutler commented 7 years ago

Also, this isn't an issue.... it's a question. This would be better asked on StackOverflow.

furyscript commented 7 years ago

We have try to run with elevate and write user administrator to service in code. If we check the options Interact with desktop it's open a dialog to confirm that seems to working but SEEM... If we not confirm dialog it's run process but without open gui I don't know why...

Edit: The process start it's ok but interact with desktop not work!! Gui are not displayed... Only we choose another window in Windows...

Edit2: We have try to create a .bat in that run our .exe but also not start file and it's get no error...

Edit3: My issue seems like to https://github.com/coreybutler/node-windows/issues/138 ..

Edit4: It's seems that process go in Background mode!!!

shalini1153 commented 4 years ago

Hello @furyscript, I seem to be having the same problem, when i run it through windows service the task goes in background... Any idea how to solve it and make it run in foreground?