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

Updated API detection logic to fallback when Powershell access is denied

This commit is contained in:
Bryan Roe
2021-11-03 12:30:38 -07:00
parent 912fdc0620
commit 06fe1aebd5
2 changed files with 12 additions and 5 deletions

View File

@@ -23,13 +23,20 @@ function netsecurityExists()
{
var child;
var command = 'Get-Module -ListAvailable -Name netsecurity';
if (require('os').arch() == 'x64')
try
{
child = require('child_process').execFile(process.env['windir'] + '\\System32\\WindowsPowerShell\\v1.0\\powershell.exe', ['/C "' + command + '"']);
if (require('os').arch() == 'x64')
{
child = require('child_process').execFile(process.env['windir'] + '\\System32\\WindowsPowerShell\\v1.0\\powershell.exe', ['/C "' + command + '"']);
}
else
{
child = require('child_process').execFile(process.env['windir'] + '\\System32\\WindowsPowerShell\\v1.0\\powershell.exe', ['/C "' + command + '"']);
}
}
else
catch(e)
{
child = require('child_process').execFile(process.env['windir'] + '\\System32\\WindowsPowerShell\\v1.0\\powershell.exe', ['/C "' + command + '"']);
return (false);
}
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
child.stderr.str = ''; child.stderr.on('data', function (c) { this.str += c.toString(); });