coreybutler / node-windows

Windows support for Node.JS scripts (daemons, eventlog, UAC, etc).
Other
2.78k stars 357 forks source link

Unable to create process with Group Managed Service Account (gMSA) #295

Closed fusscreme closed 2 years ago

fusscreme commented 2 years ago

Unable to create process with Group Managed Service Account (gMSA) I am unable to create a process with allowServiceLogon set to true. I tried various combinations of the logon-attributes as well as omitting some or all of the attributes. In the winsws documentation (of any relevance here?) it is suggested to suffix $ to the service account which I tried, too.

Weirdly, I do get the console.log but the process is never being created (I checked with powershell get-process).

If I omit allowServiceLogon and the logon-attributes the service is created just fine.

Try for instance

var Service = require('node-windows').Service;

// Create a new service object
var svc = new Service({
  name:'my-project-name',
  description: 'windows service for my node project',
  script: 'C:\\pathto\\server.js',
  allowServiceLogon: true
});

svc.logOnAs.domain = 'mydomain.local';
svc.logOnAs.account = 'servicename$';
//svc.logOnAs.password = 'password';

// Listen for the "install" event, which indicates the
// process is available as a service.
svc.on('install',function(){
  svc.start();
});

// Just in case this file is run twice.
svc.on('alreadyinstalled',function(){
  console.log('This service is already installed.');
});

// Listen for the "start" event and let us know when the
// process has actually started working.
svc.on('start',function(){
  console.log(svc.name+' started!\nVisit http://127.0.0.1:5000 to see it in action.');
});

// Install the script as a service.
svc.install();
fusscreme commented 2 years ago

Solution: Add sufficient permissions to the right folders, see here https://stackoverflow.com/questions/69181084/how-do-to-use-node-windows-with-service-account/69228712#69228712.