powerShell added default path
This commit is contained in:
parent
392473e431
commit
aff943cbe4
@ -55,6 +55,7 @@ const _sunos = (_platform === 'sunos');
|
||||
|
||||
if (_windows) {
|
||||
util.getCodepage();
|
||||
util.getPowershell();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
|
||||
16
lib/util.js
16
lib/util.js
@ -42,6 +42,7 @@ let _psChild;
|
||||
let _psResult = '';
|
||||
let _psCmds = [];
|
||||
let _psPersistent = false;
|
||||
let _powerShell = '';
|
||||
const _psToUTF8 = '$OutputEncoding = [System.Console]::OutputEncoding = [System.Console]::InputEncoding = [System.Text.Encoding]::UTF8 ; ';
|
||||
const _psCmdStart = '--###START###--';
|
||||
const _psError = '--ERROR--';
|
||||
@ -332,6 +333,16 @@ function findObjectByKey(array, key, value) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
function getPowershell() {
|
||||
_powerShell = 'powershell.exe';
|
||||
if (_windows) {
|
||||
defaultPath = `${WINDIR}\\WindowsPowerShell\\v1.0\\powershell.exe`;
|
||||
if (fs.existsSync(defaultPath)) {
|
||||
_powerShell = defaultPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getWmic() {
|
||||
if (os.type() === 'Windows_NT' && !wmicPath) {
|
||||
wmicPath = WINDIR + '\\system32\\wbem\\wmic.exe';
|
||||
@ -401,7 +412,7 @@ function powerShellProceedResults(data) {
|
||||
|
||||
function powerShellStart() {
|
||||
if (!_psChild) {
|
||||
_psChild = spawn('powershell.exe', ['-NoProfile', '-NoLogo', '-InputFormat', 'Text', '-NoExit', '-Command', '-'], {
|
||||
_psChild = spawn(_powerShell, ['-NoProfile', '-NoLogo', '-InputFormat', 'Text', '-NoExit', '-Command', '-'], {
|
||||
stdio: 'pipe',
|
||||
windowsHide: true,
|
||||
maxBuffer: 1024 * 20000,
|
||||
@ -479,7 +490,7 @@ function powerShell(cmd) {
|
||||
return new Promise((resolve) => {
|
||||
process.nextTick(() => {
|
||||
try {
|
||||
const child = spawn('powershell.exe', ['-NoProfile', '-NoLogo', '-InputFormat', 'Text', '-NoExit', '-ExecutionPolicy', 'Unrestricted', '-Command', '-'], {
|
||||
const child = spawn(_powerShell, ['-NoProfile', '-NoLogo', '-InputFormat', 'Text', '-NoExit', '-ExecutionPolicy', 'Unrestricted', '-Command', '-'], {
|
||||
stdio: 'pipe',
|
||||
windowsHide: true,
|
||||
maxBuffer: 1024 * 20000,
|
||||
@ -2595,3 +2606,4 @@ exports.semverCompare = semverCompare;
|
||||
exports.getAppleModel = getAppleModel;
|
||||
exports.checkWebsite = checkWebsite;
|
||||
exports.cleanString = cleanString;
|
||||
exports.getPowershell = getPowershell;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user