shell() added pawershell detection
This commit is contained in:
parent
c7d4751518
commit
f3c402248e
@ -1122,15 +1122,13 @@ function shell(callback) {
|
|||||||
if (_windows) {
|
if (_windows) {
|
||||||
try {
|
try {
|
||||||
const result = 'CMD';
|
const result = 'CMD';
|
||||||
util.powerShell('$PSVersionTable').then(stdout => {
|
util.powerShell(`Get-CimInstance -className win32_process | where-object {$_.ProcessId -eq ${process.ppid} } | select Name`).then(stdout => {
|
||||||
|
let result = 'CMD';
|
||||||
if (stdout) {
|
if (stdout) {
|
||||||
const lines = stdout.toString().toLowerCase().split('\n').map(line => line.replace(/ +/g, ' ').replace(/ +/g, ':'));
|
if (stdout.toString().toLowerCase().indexOf('powershell') >= 0) {
|
||||||
const ps = getValue(lines, 'psversion');
|
result = 'PowerShell';
|
||||||
let result = 'CMD';
|
|
||||||
if (ps) {
|
|
||||||
result = `PowerShell ${ps.split('.')[0] + (ps.split('.')[1] ? '.' + ps.split('.')[1] : '')}`;
|
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback(result);
|
callback(result);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user