Skip to content

Service install silently fails on Windows 11 #338

@longzheng

Description

@longzheng

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
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.

svc.on('install',function(){
  svc.start();
});

svc.on('error', (err) => {
  console.log(err)
})

svc.install();

Desktop:
Windows 11 22H2

image

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 #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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions