修复win 下管理员权限的问题

This commit is contained in:
fofolee 2019-05-13 21:22:43 +08:00
parent b9ede9c60f
commit 757e3556ca
2 changed files with 10 additions and 4 deletions

View File

@ -48,10 +48,16 @@ powershell = (cmd, callback) => {
tasklist = (callback) => {
var tasklist = [];
if (isWin) {
powershell("Get-Process -IncludeUserName | sort-object ws -descending | Select-Object ProcessName,Path,Description,WorkingSet,UserName | ConvertTo-Json", (stdout, stderr) => {
exec('net session > NULL && echo 1 || echo 0', (err, stdout, stderr) => {
let isAdmin = parseInt(stdout),
IncludeUserName = isAdmin ? '-IncludeUserName' : '',
UserName = isAdmin ? ',UserName' : '';
powershell(`Get-Process ${IncludeUserName} | sort-object ws -descending | Select-Object ProcessName,Path,Description,WorkingSet${UserName} | ConvertTo-Json`, (stdout, stderr) => {
stderr && dialog.showMessageBox(BrowserWindow.getFocusedWindow(), { type: 'error', title: '啊嘞?!', message: stderr })
tasklist = JSON.parse(stdout);
callback(tasklist);
});
})
} else {
exec('ps -A -o pid -o %cpu -o %mem -o user -o comm | sed 1d | sort -rnk 3', (err, stdout, stderr) => {
lines = stdout.split('\n');

Binary file not shown.