我有两个同名的进程
C:\wamp\bin\mysql>tasklist /FI "IMAGENAME eq mysqld.exe" 2>NUL | find /I /N"mysqld.exe"
[4]mysqld.exe 2868 Services 0 3,072 K
[5]mysqld.exe 9964 Services 0 37,680 K
mysqld.exe 的两个进程在不同的文件夹中。我想检查特定文件夹中的某个 mysqld.exe 是否正在运行。可以吗?谢谢。
我正在使用 Windows 7。
答案1
Windows 管理规范可以执行您要查找的操作,即显示文件路径或进程的完整命令行:
wmic process where "name='mysqld.exe'" get ProcessID, ExecutablePath
or
wmic process where "name='mysqld.exe'" get ProcessID, ExecutablePath /FORMAT:LIST
该CommandLine
选项将显示任何启动开关,例如目标数据路径或 TCP 端口
以下是 explorer.exe 的示例输出:
C:\Users\Richie>wmic process where "name='explorer.exe'" get ProcessID, ExecutablePath, CommandLine /FORMAT:LIST
CommandLine=C:\Windows\Explorer.EXE
ExecutablePath=C:\Windows\Explorer.EXE
ProcessId=3268
CommandLine=C:\Windows\explorer.exe /factory,{ceff45ee-c862-41de-aee2-a022c81eda92} -Embedding
ExecutablePath=C:\Windows\explorer.exe
ProcessId=4236
C:\Users\Richie>wmic process where "name='explorer.exe'" get ProcessID, ExecutablePath, CommandLine
CommandLine ExecutablePath ProcessId
C:\Windows\Explorer.EXE C:\Windows\Explorer.EXE 3268
C:\Windows\explorer.exe /factory,{ceff45ee-c862-41de-aee2-a022c81eda92} -Embedding C:\Windows\explorer.exe 4236
答案2
这在 powershell 中
PS C:\> gwmi Win32_Process | select Handle, CommandLine | format-list
PS C:\> gwmi Win32_Process -filter "name='chrome.exe'" | select Handle, CommandLine | format-list