mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-11-07 12:52:54 -05:00
add extra services information
Signed-off-by: si458 <simonsmith5521@gmail.com>
This commit is contained in:
@@ -1304,6 +1304,41 @@ function handleServerCommand(data) {
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'service': {
|
||||
// return information about the service
|
||||
try {
|
||||
var service = require('service-manager').manager.getService(data.serviceName);
|
||||
if (service != null) {
|
||||
var reply = {
|
||||
name: (service.name ? service.name : ''),
|
||||
status: (service.status ? service.status : ''),
|
||||
startType: (service.startType ? service.startType : ''),
|
||||
failureActions: (service.failureActions ? service.failureActions : ''),
|
||||
installedDate: (service.installedDate ? service.installedDate : ''),
|
||||
installedBy: (service.installedBy ? service.installedBy : '') ,
|
||||
user: (service.user ? service.user : '')
|
||||
};
|
||||
if(reply.installedBy.indexOf('S-1-5') != -1) {
|
||||
var cmd = "(Get-WmiObject -Class win32_userAccount -Filter \"SID='"+service.installedBy+"'\").Caption";
|
||||
var replydata = "";
|
||||
var pws = require('child_process').execFile(process.env['windir'] + '\\System32\\WindowsPowerShell\\v1.0\\powershell.exe', ['powershell', '-noprofile', '-nologo', '-command', '-'], {});
|
||||
pws.descriptorMetadata = 'UserSIDPowerShell';
|
||||
pws.stdout.on('data', function (c) { replydata += c.toString(); });
|
||||
pws.stderr.on('data', function (c) { replydata += c.toString(); });
|
||||
pws.stdin.write(cmd + '\r\nexit\r\n');
|
||||
pws.on('exit', function () {
|
||||
if (replydata != "") reply.installedBy = replydata;
|
||||
mesh.SendCommand({ action: 'msg', type: 'service', value: JSON.stringify(reply), sessionid: data.sessionid });
|
||||
delete pws;
|
||||
});
|
||||
} else {
|
||||
mesh.SendCommand({ action: 'msg', type: 'service', value: JSON.stringify(reply), sessionid: data.sessionid });
|
||||
}
|
||||
}
|
||||
} catch (ex) {
|
||||
mesh.SendCommand({ action: 'msg', type: 'service', error: ex, sessionid: data.sessionid })
|
||||
}
|
||||
}
|
||||
case 'services': {
|
||||
// Return the list of installed services
|
||||
var services = null;
|
||||
|
||||
Reference in New Issue
Block a user