coreybutler / coreybutler/node-windows
Service install silently fails on Windows 11
- Dominant language
- JavaScript
- Stars
- 2.9k
- Forks
- 368
- PR merge metrics
- No merged PRs in 30d
Description
**Issue:**
When using `svc.install();` the service fails to install in Windows 11 without any warning or error.
**How To Reproduce:**
1. Start with a blank Windows 11 environment (e.g. use "Windows Sandbox")
2. Install node
3. Create project with `npm install node-windows`
4. Run sample service install script
```js
var Service = require('node-windows').Service;
// Create a new service object
var svc = new Service({
name:'Hello World',
description: 'The nodejs.org example web server.',
script: 'C:\\path\\to\\helloworld.js',
nodeOptions: [
'--harmony',
'--max_old_space_size=4096'
]
//, workingDirectory: '...'
//, allowServiceLogon: true
});
// Listen for the "install" event, which indicates the
// process is available as a service.
svc.on('install',function(){
svc.start();
});
svc.install();
```
**Expected Behavior:**
Service is installed.
Or, error is emitted.
**Actual Behavior:**
Service is not installed.
Even adding an error event handler, there is no error emitted.
```js
svc.on('install',function(){
svc.start();
});
svc.on('error', (err) => {
console.log(err)
})
svc.install();
```
**Desktop:**
Windows 11 22H2

**Additional context:**
I believe the issue is related to the very old version of `winsw.exe` bundled with the project. https://github.com/coreybutler/node-windows/tree/master/bin/winsw
If I try to run `winsw.exe` directly (but providing it a sample `.xml` to install a service), it fails. However if I use a newer version of `winsw.exe` from https://github.com/winsw/winsw/releases/tag/v2.12.0 then the service is installed correctly.
I believe this PR attempting to upgrade WinSW https://github.com/coreybutler/node-windows/pull/268 ~~might address this issue~~ (EDIT: Nope, unfortunately that version of WinSW doesn't work either. I tested 2.12.0 directly and works https://github.com/winsw/winsw/releases/tag/v2.12.0.
Contributor guide
Assessment
This issue has not been assessed yet.