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