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

EPERM error when uninstalling the service #324

Open
nemqe opened this issue Oct 5, 2022 · 3 comments
Open

EPERM error when uninstalling the service #324

nemqe opened this issue Oct 5, 2022 · 3 comments

Comments

@nemqe
Copy link

nemqe commented Oct 5, 2022

Issue:
When I run the example uninstall script I get the EPERM: operation not permitted, unlink... error.

Files are deleted but the service is sometimes not, and when I run the script again I get the Uninstall was skipped... meesage.

I am trying to run the example hello_word service and I am running the commands as the Administrator. Not sure if I should run the scripts as a different user?

How To Reproduce:

  1. Clone node-windows repo
  2. Go to example directory where the hello_word program is
  3. Run npm install
  4. Run npm link node-windows
  5. Run install script
  6. Run uninstall script
  7. Error is displayed, service is not deleted

Expected Behaviour:
I would expect the service to be deleted without an error.

Server:

  • OS: Windows Server 2022
@seidhkona
Copy link

I'm seeing the same issue on Windows 10. Any updates or insight on what's causing it?

@longzheng
Copy link

I fixed by manually specifying a longer wait time, the default 2 seconds don't seem to be long enough (between uninstalling the service and deleting the daemon file).

svc.uninstall(5);

@khelkun
Copy link

khelkun commented Apr 13, 2023

  1. Error is displayed, service is not deleted

In my case, I'd say the service is deleted from Windows services.msc, but node-windows fails to delete mydaemon.wrapper.log because it's not permitted to do it. It's clearly not a wait time issue in my case:

Error: EPERM: operation not permitted, unlink 'C:\mydaemon\daemon\ftlnodeagent.wrapper.log'
    at Object.unlinkSync (node:fs:1767:3)
    at rm (C:\Users\myuser\AppData\Roaming\npm\node_modules\node-windows\lib\daemon.js:602:22)
    at C:\Users\threedeeverse\AppData\Roaming\npm\node_modules\node-windows\lib\daemon.js:610:15
    at ChildProcess.exithandler (node:child_process:394:7)
    at ChildProcess.emit (node:events:513:28)
    at maybeClose (node:internal/child_process:1100:16)
    at Socket.<anonymous> (node:internal/child_process:458:11)
    at Socket.emit (node:events:513:28)
    at Pipe.<anonymous> (node:net:301:12) {
  errno: -4048,
  syscall: 'unlink',
  code: 'EPERM',
  path: 'C:\\mydaemon\\daemon\\ftlnodeagent.wrapper.log'

This does happen on a VM (Windows Server 2019) but does not happen on my workstation (Windows 10). Both installs the service with logOnAs with the main administrator user from a regular command line (non elevated).
Strangely on the VM, if the svc.uninstall() is run from a regular command line, then it's not permitted to delete ftlnodeagent.wrapper.log. But if it's run from an administrator command line then it succeeds to delete ftlnodeagent.wrapper.log.
If I review the security tab of the log file properties then the "group or user names" and premissions are clearly different on the Windows Server 2019 VM.

Workaround:
Pre-create the .wrapper.log .out.log .err.log from my installation script before calling svc.install(). So the user who installs the service has permissions to delete those file when calling svc.uninstall().

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

No branches or pull requests

4 participants