プロセス名をその説明から取得しますか?

プロセス名をその説明から取得しますか?

プロセスの説明に応じてループを使用して、コンピューターのメモリからプロセス名を取得するにはどうすればよいですか?

例:

私のプログラム名はメモリ内では「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」にはメモリ内に 2 つのプロセスが存在します。

関連情報