자체 설명에서 프로세스 이름을 얻으시겠습니까?

자체 설명에서 프로세스 이름을 얻으시겠습니까?

프로세스 설명에 따라 루프를 사용하여 컴퓨터 메모리에서 프로세스 이름을 어떻게 얻을 수 있습니까?

예:

내 프로그램 이름은 메모리에 "dev.exe"이고 설명은 "PHP 개발자를 돕는 도구"입니다.

사용자가 이름을 변경하더라도 프로세스 설명을 사용하여 내 프로세스 이름을 찾을 수 있는 방법이 있나요?

autoit이나 cmd 또는 wmic로 이 작업을 수행할 수 있나요?

답변1

동일한 문제를 해결하려고 이 링크를 찾았습니다. 기존 답변을 토대로 기존 스크립트에 추가할 수 있는 간단한 줄은 다음과 같습니다.

 Get-Process | where {$_.Description -like '*note*'} | select Path, Description, ProcessName

예제 출력:

    Path                                                         Description          ProcessName
----                                                         -----------          -----------
C:\Windows\system32\notepad.exe                              Notepad              notepad
C:\Program Files\Microsoft Office\root\Office16\ONENOTE.EXE  Microsoft OneNote    ONENOTE
C:\Program Files\Microsoft Office\root\Office16\ONENOTEM.EXE Send to OneNote Tool ONENOTEM

답변2

"파일 설명" 속성 값이 주어지면 실행 중인 프로세스 이름을 어떻게 찾나요?

개선된 솔루션(채팅 토론에 이어 @BenN에게 감사드립니다):

다음 PowerShell 스크립트(Get-ProcessName.ps1)를 사용합니다.

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

노트:

  • 스크립트에 전달된 첫 번째 매개변수는 "파일 설명" 속성 값 내에서 대소문자를 구분하지 않는 검색을 수행하는 데 사용됩니다.
  • "notepad"를 전달하면 "notepad.exe"와 "notepad++.exe"가 둘 다 실행 중인 경우 둘 다 일치합니다.

예제 출력:

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>

독창적인 솔루션:

다음 Powershell 스크립트(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)'"
      }
    }
  }

노트:

  • 스크립트에 전달된 첫 번째 매개변수는 "파일 설명" 속성 값 내에서 "와일드카드" 대소문자를 구분하지 않는 검색을 수행하는 데 사용됩니다.
  • 통과하면 "파일 설명" 속성을 string사용하여 검색 *string*하고 일치합니다.string
  • "notepad"를 전달하면 "notepad.exe"와 "notepad++.exe"가 둘 다 실행 중인 경우 둘 다 일치합니다.
  • 스크립트는 "파일 설명", "프로세스 경로" 및 "프로세스 이름"을 출력합니다.

예제 출력:

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>

노트:

  • "notepad++.exe"는 휴대용 버전을 실행할 때 메모리에 두 개의 프로세스가 있습니다.

관련 정보