Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to execute child process #270

Open
shalini1153 opened this issue Aug 14, 2020 · 7 comments
Open

Unable to execute child process #270

shalini1153 opened this issue Aug 14, 2020 · 7 comments

Comments

@shalini1153
Copy link

I have a created a windows service using node-windows and it seems to work properly. But as soon as I have my child process call it does not execute my child process and if i switch to running it from cmd instead as a service it opens my executable.
This is nothing related to type of user as i only have one user as administrator
Below is my code

Tried using spawn
const command = 'jre-8u261-windows-x64.exe'
const bat = spawn(command, [],{
shell: true, // use to run in a shell if you need
detached: true, // important
stdio: "ignore",
});

Using exec:
const test = exec('jre-8u261-windows-x64.exe' );
Please suggest

@coreybutler
Copy link
Owner

Have you reviewed the wiki?

When it isn't permission problems, it's usually a path problem.

@shalini1153
Copy link
Author

Yes i have reviewed your wiki and this is not a path problem because i can see my task running in background process in task manager while running it with service
But the same runs as foreground task by running the program from cmd

@shalini1153
Copy link
Author

This issue has been reported multiple times... Please suggest something so that we can make it working

@coreybutler
Copy link
Owner

This is pretty specific to your environment, and there's not much I can do to diagnose if there's no way to recreate the problem. Perhaps you could put a gist up with your code.

"this is not a path problem because i can see my task running in background process in task manager while running it with service" - this doesn't mean the process can find your executable. It just means the daemon is running. The only thing I can think of is to try using the absolute path to the executable, i.e.

const command = 'C:\\\\path\\to\\jre-8u261-windows-x64.exe'

The double backslash will escape the path so the script is recognized as C:\\path\to\jre-8u261-windows-x64.exe.

What other issues are you referring to when you say this has been reported multiple times? This appears to be the first issue you've opened.

@shalini1153
Copy link
Author

I tried adding absolute path This is my code now
const command = 'C:\\\\Users\\Test\\Desktop\\jre-8u261-windows-x64.exe';
const bat = spawn(command, [],{
shell: true,
detached: true,
stdio: "inherit"
});
bat.unref();
return true;

Also on further debugging i can see my task here in Task manager
Task Manager 1

And also when i did right click on task and properties. I can find my exe file on the path mentioned
Windows Path

Also this issue is on every windows machine which i tested

@shalini1153
Copy link
Author

shalini1153 commented Aug 16, 2020

Also these were the issue which i was refering to
#55
#163
I am also facing similar issue

@darklightcode
Copy link

This issue is still present, my script opens a detached process, which behaves correct, paths are absolute, no errors in the Service logs/output nor cli. I'm using in the detached process node-notifier. When starting the script from CLI the notifications are popping up, but not when the script is run by the Service. node-notifier uses some other exe for creating windows toasts. The Toast process appears in task manager, but its not triggered as it should.

Workaround: I've opened Services > TheGeneratedService > Log On(tab) > checked This Account and used my account which is an administrator. Then I've restarted the service as prompted, and it worked as intended.

I have tried to recreate the service with svc.logOnAs.(domain|username|password) and it created the service but it was identical as without the credentials, wasn't it supposed to behave like in the "workaround" above ?

I've found a similar situation on SO which reflects this elevation issue at service level:
https://stackoverflow.com/questions/61971517/powershell-send-a-toast-notification-to-logged-user-when-running-as-local-syste

Maybe someone can tackle this problem.

Windows 10: 19042.804 20H2
Node: v14.15.5
node-windows: 1.0.0-beta.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants