получить имя процесса из его собственного описания?

1469
Qassam Mahmoud

Как я могу получить имя процесса из памяти компьютера, используя цикл в зависимости от описания процесса?

Пример:

Моя программа называется «dev.exe» в памяти, а ее описание - «инструмент помощи разработчикам php».

Есть ли способ найти имя моего процесса, используя описание процесса, даже если пользователь изменил имя?

Можем ли мы сделать это autoit или cmd или wmic?

2
Просто идея. В принципе, вы можете иметь список всех процессов, затем имя исполняемого файла и путь; когда размер совпадает, вы можете запустить что-то вроде [md5sum] (https://en.wikipedia.org/wiki/Md5sum) и проверить, являются ли они одним файлом, или вы можете извлечь, если есть, внутреннее имя и версию. (Некоторые программы скомпилированы под своим именем ...) [Как составить список процессов] (http://superuser.com/questions/914782/how-do-you-list-all-processes-on-the-command-line в окнах) может дать вам несколько подсказок ... Hastur 7 лет назад 0
пожалуйста, любая помощь? Qassam Mahmoud 7 лет назад 0
@QassamMahmoud В своем ответе я представил два решения PowerShell. DavidPostill 7 лет назад 0

1 ответ на вопрос

2
DavidPostill

How do I find a running Process Name given it's "File description" property value?

Improved solution (thanks to @BenN following discussion in chat):

Use the following PowerShell Script (Get-ProcessName.ps1).

$_match=$Args[0].ToLowerInvariant() Get-Process | where {$_.Description -ne $null -and $_.Description.ToLowerInvariant().Contains($_match)} | select Path, Description, ProcessName 

Notes:

  • The first parameter passed to the script is used to perform a case insensitive search within the "File description" property value.
  • Passing "notepad" will match both "notepad.exe" and "notepad++.exe" if they are both running.

Example output:

PS F:\test> .\Get-ProcessName notepad Path Description ProcessName ---- ----------- ----------- C:\Windows\system32\notepad.exe Notepad notepad E:\LiberKey\Apps\Notepad++\App\Notepad++\notepad++.exe Notepad++ : a free (GNU) source code editor notepad++ E:\LiberKey\Apps\Notepad++\App\Notepad++\notepad++.exe Notepad++ : a free (GNU) source code editor notepad++ PS F:\test> 

Original solution:

Use the following Powershell Script (Get-ProcessName.ps1).

$_name=$Args[0] $_match="*"+$Args[0]+"*" Get-Process | ForEach { if ($_.Path) { $_filedescription=(Get-Item $_.Path).VersionInfo.FileDescription if ($_filedescription -like $_match) { Write-Output "File Description: '$_filedescription', Process Path: '$($_.Path)', Process Name: '$($_.ProcessName)'" } } } 

Notes:

  • The first parameter passed to the script is used to perform a "wildcard" case insensitive search within the "File description" property value.
  • If you pass string it will search using *string* and will match string anywhere within the "File description" property
  • Passing "notepad" will match both "notepad.exe" and "notepad++.exe" if they are both running.
  • The script outputs the "File Description", "Process Path" and "Process Name.

Example output:

PS F:\test> .\Get-ProcessName notepad File Description: 'Notepad', Process Path: 'C:\Windows\system32\notepad.exe', Process Name: 'notepad' File Description: 'Notepad++ : a free (GNU) source code editor', Process Path: 'E:\LiberKey\Apps\Notepad++\App\Notepad++\notepad++.exe', Process Name: 'notepad++' File Description: 'Notepad++ : a free (GNU) source code editor', Process Path: 'E:\LiberKey\Apps\Notepad++\App\Notepad++\notepad++.exe', Process Name: 'notepad++' PS F:\test> 

Notes:

  • "notepad++.exe" has two processes in memory when running the portable version.