Display complete command line (including arguments) for Windows process

I want to display a process's command line (including any arguments) from the command line itself. In other words, I want to show the "Command Line" column in the Task Manager but from a command line. Is this possible?

For example, the output might look something like

C:\java\bin\java.exe -Dhttp.proxyHost=http://localproxy -Dport=8331

Solution 1:

You can use Microsoft's official Process Explorer. It can do exactly this and has many many more useful features.

Solution 2:

Wmic.exe will show you what you are looking for:

wmic path win32_process get name,commandline > commandline.txt

Java looks like:

"C:\Program Files\Java\jre6\bin\jqs.exe" -service -config "C:\Program Files\Java\jre6\lib\deploy\jqs\jqs.conf"

For all available attributes, try:

wmic path win32_process get /format:list