powershell() added NoProfile to speed up powershell (windows)
This commit is contained in:
parent
d484f78552
commit
77de32f9ad
@ -82,6 +82,7 @@ For major (breaking) changes - **version 4, 3 and 2** - see end of page.
|
||||
|
||||
| Version | Date | Comment |
|
||||
| ------- | ---------- | --------------------------------------------------------------------------------------------------- |
|
||||
| 5.17.15 | 2023-05-29 | `powershell()` added NoProfile to speed up powershell (windows) |
|
||||
| 5.17.14 | 2023-05-29 | `diskLayout()`, `osInfo()` fix parsing issues (mac OS) |
|
||||
| 5.17.13 | 2023-05-24 | `typings` fix typings dynamicData, networkInterfaceDatass |
|
||||
| 5.17.12 | 2023-02-28 | `uuid()` fix unique mac address issue (Android) |
|
||||
|
||||
@ -57,6 +57,11 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th scope="row">5.17.15</th>
|
||||
<td>2023-05-29</td>
|
||||
<td><span class="code">powerShell()</span> added NoProfile attribute (windows)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">5.17.14</th>
|
||||
<td>2023-05-29</td>
|
||||
|
||||
@ -1053,7 +1053,7 @@ function getUniqueMacAdresses() {
|
||||
for (let dev in ifaces) {
|
||||
if ({}.hasOwnProperty.call(ifaces, dev)) {
|
||||
ifaces[dev].forEach(function (details) {
|
||||
if (details && details.mac && details.mac !== '00:00:00:00:00:00') {
|
||||
if (details?.mac && details.mac !== '00:00:00:00:00:00') {
|
||||
const mac = details.mac.toLowerCase();
|
||||
if (macs.indexOf(mac) === -1) {
|
||||
macs.push(mac);
|
||||
|
||||
16
lib/util.js
16
lib/util.js
@ -315,7 +315,7 @@ function getWmic() {
|
||||
if (!fs.existsSync(wmicPath)) {
|
||||
try {
|
||||
const wmicPathArray = execSync('WHERE WMIC', execOptsWin).toString().split('\r\n');
|
||||
if (wmicPathArray && wmicPathArray.length) {
|
||||
if (wmicPathArray?.length) {
|
||||
wmicPath = wmicPathArray[0];
|
||||
} else {
|
||||
wmicPath = 'wmic';
|
||||
@ -378,14 +378,14 @@ function powerShellProceedResults(data) {
|
||||
|
||||
function powerShellStart() {
|
||||
if (!_psChild) {
|
||||
_psChild = spawn('powershell.exe', ['-NoLogo', '-InputFormat', 'Text', '-NoExit', '-Command', '-'], {
|
||||
_psChild = spawn('powershell.exe', ['-NoProfile', '-NoLogo', '-InputFormat', 'Text', '-NoExit', '-Command', '-'], {
|
||||
stdio: 'pipe',
|
||||
windowsHide: true,
|
||||
maxBuffer: 1024 * 20000,
|
||||
encoding: 'UTF-8',
|
||||
env: util._extend({}, process.env, { LANG: 'en_US.UTF-8' })
|
||||
});
|
||||
if (_psChild && _psChild.pid) {
|
||||
if (_psChild?.pid) {
|
||||
_psPersistent = true;
|
||||
_psChild.stdout.on('data', function (data) {
|
||||
_psResult = _psResult + data.toString('utf8');
|
||||
@ -436,7 +436,7 @@ function powerShell(cmd) {
|
||||
start: new Date()
|
||||
});
|
||||
try {
|
||||
if (_psChild && _psChild.pid) {
|
||||
if (_psChild?.pid) {
|
||||
_psChild.stdin.write(_psToUTF8 + 'echo ' + _psCmdStart + id + _psIdSeperator + '; ' + os.EOL + cmd + os.EOL + 'echo ' + _psCmdSeperator + os.EOL);
|
||||
}
|
||||
} catch (e) {
|
||||
@ -451,7 +451,7 @@ function powerShell(cmd) {
|
||||
return new Promise((resolve) => {
|
||||
process.nextTick(() => {
|
||||
try {
|
||||
const child = spawn('powershell.exe', ['-NoLogo', '-InputFormat', 'Text', '-NoExit', '-ExecutionPolicy', 'Unrestricted', '-Command', '-'], {
|
||||
const child = spawn('powershell.exe', ['-NoProfile', '-NoLogo', '-InputFormat', 'Text', '-NoExit', '-ExecutionPolicy', 'Unrestricted', '-Command', '-'], {
|
||||
stdio: 'pipe',
|
||||
windowsHide: true,
|
||||
maxBuffer: 1024 * 20000,
|
||||
@ -464,7 +464,7 @@ function powerShell(cmd) {
|
||||
resolve(result);
|
||||
});
|
||||
}
|
||||
if (child && child.pid) {
|
||||
if (child?.pid) {
|
||||
child.stdout.on('data', function (data) {
|
||||
result = result + data.toString('utf8');
|
||||
});
|
||||
@ -514,7 +514,7 @@ function execSafe(cmd, args, options) {
|
||||
resolve(result);
|
||||
});
|
||||
}
|
||||
if (child && child.pid) {
|
||||
if (child?.pid) {
|
||||
child.stdout.on('data', function (data) {
|
||||
result += data.toString();
|
||||
});
|
||||
@ -576,7 +576,7 @@ function smartMonToolsInstalled() {
|
||||
if (_windows) {
|
||||
try {
|
||||
const pathArray = execSync('WHERE smartctl 2>nul', execOptsWin).toString().split('\r\n');
|
||||
if (pathArray && pathArray.length) {
|
||||
if (pathArray?.length) {
|
||||
_smartMonToolsInstalled = pathArray[0].indexOf(':\\') >= 0;
|
||||
} else {
|
||||
_smartMonToolsInstalled = false;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user