1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2025-12-22 19:23:31 +00:00

Updated win-dispatcher to use win-tasks, falling back to legacy SCHTASKS/POWERSHELL, to speed up dispatching

This commit is contained in:
Bryan Roe
2022-03-08 13:00:35 -08:00
parent 6030154d94
commit 7c4aa3318f
2 changed files with 35 additions and 1 deletions

File diff suppressed because one or more lines are too long

View File

@@ -80,6 +80,40 @@ function dispatch(options)
this.parent.emit('connection', s); this.parent.emit('connection', s);
}); });
try
{
var user = null;
var domain = null;
if(options.user == null)
{
if (require('user-sessions').getProcessOwnerName(process.pid).tsid == 0)
{
user = 'SYSTEM'
}
else
{
var info = require('user-sessions').getProcessOwnerName(process.pid);
user = info.name;
domain = info.domain;
}
}
else
{
var tokens = options.user.split('\\');
if(tokens.length!=2) { throw('invalid user format');}
user = tokens[1];
domain = tokens[0];
}
var task = { name: 'MeshUserTask', user: user, domain: domain, execPath: process.execPath, arguments: ['-b64exec ' + str] };
require('win-tasks').addTask(task);
require('win-tasks').getTask({ name: 'MeshUserTask' }).run();
require('win-tasks').deleteTask('MeshUserTask');
return (ret);
}
catch(xx)
{}
var taskoptions = { env: { _target: process.execPath, _args: '-b64exec ' + str, _user: '"' + options.user + '"' } }; var taskoptions = { env: { _target: process.execPath, _args: '-b64exec ' + str, _user: '"' + options.user + '"' } };
for (var c1e in process.env) for (var c1e in process.env)
{ {