users() fix when multiple explorer.exe (windows)

This commit is contained in:
Sebastian Hildebrandt
2022-12-08 16:51:40 +01:00
parent 7bf36a6d64
commit a669a71045
4 changed files with 12 additions and 6 deletions
+1 -1
View File
@@ -209,7 +209,7 @@ function users(callback) {
try {
let cmd = 'Get-CimInstance Win32_LogonSession | select LogonId,@{n="StartTime";e={$_.StartTime.ToString("yyyy-MM-dd HH:mm:ss")}} | fl' + '; echo \'#-#-#-#\';';
cmd += 'Get-CimInstance Win32_LoggedOnUser | select antecedent,dependent | fl ' + '; echo \'#-#-#-#\';';
cmd += '$process = (Get-CimInstance Win32_Process -Filter "name = \'explorer.exe\'"); Invoke-CimMethod -InputObject $process -MethodName GetOwner | select user, domain | fl; get-process -name explorer | select-object sessionid | fl; echo \'#-#-#-#\';';
cmd += '$process = (Get-CimInstance Win32_Process -Filter "name = \'explorer.exe\'"); Invoke-CimMethod -InputObject $process[0] -MethodName GetOwner | select user, domain | fl; get-process -name explorer | select-object sessionid | fl; echo \'#-#-#-#\';';
cmd += 'query user';
util.powerShell(cmd).then((data) => {
if (data) {