Open nemqe opened 2 years ago
I'm seeing the same issue on Windows 10. Any updates or insight on what's causing it?
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);
- 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()
.
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:
npm install
npm link node-windows
Expected Behaviour: I would expect the service to be deleted without an error.
Server: