1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2025-12-24 04:04:31 +00:00

1. Added 'global' polyfill

2. Updated service-manager in Native and JS, to add '_installedBy' on Windows
This commit is contained in:
Bryan Roe
2019-11-20 14:41:22 -08:00
parent e68d0cc7c5
commit bca47688ff
4 changed files with 186 additions and 128 deletions

View File

@@ -618,6 +618,21 @@ function serviceManager()
}
}
});
Object.defineProperty(retVal, 'installedBy',
{
get: function()
{
var reg = require('win-registry');
try
{
return(reg.QueryKey(reg.HKEY.LocalMachine, 'SYSTEM\\CurrentControlSet\\Services\\' + this.name, '_InstalledBy'));
}
catch(xx)
{
return (null);
}
}
});
if (retVal.status.state != 'UNKNOWN')
{
require('events').EventEmitter.call(retVal);
@@ -1532,6 +1547,7 @@ function serviceManager()
if (process.platform == 'win32')
{
var reg = require('win-registry');
if (!this.isAdmin()) { throw ('Installing as Service, requires admin'); }
// Before we start, we need to copy the binary to the right place
@@ -1616,13 +1632,24 @@ function serviceManager()
}
}
}
if (options.parameters)
{
var reg = require('win-registry');
var imagePath = reg.QueryKey(reg.HKEY.LocalMachine, 'SYSTEM\\CurrentControlSet\\Services\\' + options.name, 'ImagePath');
imagePath += (' ' + options.parameters.join(' '));
reg.WriteKey(reg.HKEY.LocalMachine, 'SYSTEM\\CurrentControlSet\\Services\\' + options.name, 'ImagePath', imagePath);
}
try
{
reg.WriteKey(reg.HKEY.LocalMachine, 'SYSTEM\\CurrentControlSet\\Services\\' + options.name, '_InstalledBy', reg.usernameToUserKey(require('user-sessions').getProcessOwnerName(process.pid).name));
}
catch (xx)
{
}
}
if (process.platform == 'freebsd')
{