mirror of
https://github.com/Ylianst/MeshAgent
synced 2025-12-22 11:13:21 +00:00
Updated win-dispatcher to use win-tasks, falling back to legacy SCHTASKS/POWERSHELL, to speed up dispatching
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -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)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user