문제

As we all know all java processes appear in task manager as javaw.exe. I want to get command line of all such java processes. A tool called ProcessExplorer does the same thing but it displays all that in a GUI and i am looking at a programming solution for the same.

Here is a snapshot from ProcessExplorer tool.

enter image description here

Any ideas??

도움이 되었습니까?

해결책

You can get it with WMIC

C:\> wmic process where(name="javaw.exe") get commandline

다른 팁

If a command line solution helps and you have Windows Powershell available, you can use something like

PS> $c = Get-WmiObject Win32_Process -Filter "name='javaw.exe'" | select-Object CommandLine
PS> $x.CommandLine
"C:\Program Files (x86)\Java\jre7\bin\java.exe" "-Djava.class.path=C:\\PROGRA~2\\Java\\jre7\\classes" ...

use the command jps to find java processes

http://docs.oracle.com/javase/1.5.0/docs/tooldocs/share/jps.html

With command prompt in windows, you can run below command

wmic process where(name="javaw.exe") get commandline

Sample Output with Command Prompt

CommandLine

"C:\Users\Public\agent\jre\bin\javaw.exe" -cp .\agent-jar-with-dependencies.jar com.agent.Runner

With powershell prompt, you can run below command

Get-WmiObject -Class Win32_Process -Filter "Name='javaw.exe'" | select-Object CommandLine

Sample Output with Powershell command

CommandLine
-----------
"C:\Users\Public\agent\jre\bin\javaw.exe" -cp .\agent-jar-with-dependencies.jar com.agent.Runner
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top