sambha
sambha

Reputation: 1353

How to get name of user account running a process on Windows command line?

I parse the output of wmic to get pid (process identifier), command line, etc. of a running process. Unfortunately user name (user executing this process) is missing from wmic output.

Is there a method to get the name of the user account?

Example wmic command:

wmic process where caption="explorer.exe"

Output:

Caption       CommandLine              CreationClassName  CreationDate    ...
explorer.exe  C:\Windows\Explorer.EXE  Win32_Process      20180214220330. ...

Upvotes: 1

Views: 6244

Answers (1)

Mofi
Mofi

Reputation: 49086

One possibility is using the command TASKLIST:

tasklist /V /FI "IMAGENAME eq explorer.exe"

Run in a command prompt window tasklist /? for help on this command which explains the used options.

The same command line for usage in a batch file with full qualified file name:

%SystemRoot%\System32\tasklist.exe /V /FI "IMAGENAME eq explorer.exe"

Upvotes: 2

Related Questions