windowscmd

Find Task-Manager Description Column from CMD?


Is there a way to find the description of a process as it is displayed in the task manager?

Task Manager

I have tried using wmic process get ProcessID, Description | find "4308", however this seems to return the name.

CMD using wmic


Solution

  • This description column looks like the description attribute of the executable file. We will thus first try to get the path to this executable and then get the description from the executable file.

    This is probably possible with WMIC, but it requires you to first get the executable path, then get the file attributes from the executable using that path using WMIC or other standard Windows executables.

    Here is how to get the executable path with WMIC:

    wmic process where "ProcessID=4308" get ExecutablePath
    

    This doesn't return a clean path, so we need to process it a bit before being able to use it for other commands to fetch the file attributes, but I'm not sure how to get the file description with WMIC.

    I do know that Powershell is way more powerful than CMD so if you are fine with using Powershell as a tool instead of WMIC, we can have a lot more control and do it in a single line:

    powershell (Get-Item (Get-Process -Id 4308).Path).VersionInfo.FileDescription
    

    We can place the result of this in a cmd variable by building some messy commands:

    for /f "usebackq delims=" %i in (`powershell ^(get-item ^(get-process -Id 4308^).Path^).VersionInfo.FileDescription`) do set description=%i
    echo %description%
    

    and then make the process ID variable too:

    set processId=4308
    for /f "usebackq delims=" %i in (`powershell ^(get-item ^(get-process -Id %processId%^).Path^).VersionInfo.FileDescription`) do set description=%i
    echo %description%
    

    If you don't want to use Powershell you'll have to find out how to get this file description attribute from a given path. I haven't immediately found an obvious way on how to do it without Powershell.

    Keep in mind to place this in a batch file, I believe you need to replace the %i with %%i. You can then do @echo off to hide the commands.

    Definitely an interesting question. Welcome!