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