You can get it with WMIC
C:\> wmic process where(name="javaw.exe") get commandline
質問
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.
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