How do I find out command line arguments of a running program?

I'm looking for a tool or method to find out what command line parameters have been passed to a program, for example when it was run by another program (launcher-application scenario).


You can do that using Process Explorer.

Just hover with your mouse over a process to see the command line arguments used to start it:
List of "chrome.exe" processes

Alternatively, you can open the properties of the process and inspect the command line right there:
Properties of a "chrome.exe" process


You can do it without Process Explorer, too, using Windows' WMI service. Run the following from the command prompt:

WMIC path win32_process get Caption,Processid,Commandline

If you want to dump the output to a file (makes it a bit easier to read), use the /OUTPUT switch:

WMIC /OUTPUT:C:\Process.txt path win32_process get Caption,Processid,Commandline

One can also achieve that by using Task Manager.

Open task manager (by CTRL-SHIFT-ESC, CTRL-ALT-DELETE or any other method).

For Windows 7 (and probably Windows XP):

  • Go to "Processes" tab. The on the "View" menu, select "Select Columns...".
  • Check the checkbox of "Command Line" and click OK. (You may have to scroll down to find it)

For Windows 8:

  • Go to "Details" tab. Right-click on any of the columns (eg. Names, PID etc.) and select "Select columns".
  • Check the checkbox of "Command Line" and click OK. (You may have to scroll down to find it)

A column of Command lines of will be added to the currently displayed columns.


PowerShell to the rescue.

Find:

Get-WmiObject Win32_Process -Filter "name = 'perl.exe'" | where {$_.CommandLine -eq '"C:\strawberry\perl\bin\perl.exe" t/Server_PreFork.t'}

And kill as bonus:

Get-WmiObject Win32_Process -Filter "name = 'perl.exe'" | where {$_.CommandLine -eq '"C:\strawberry\perl\bin\perl.exe" t/Server_PreFork.t'} | ForEach-Object { Invoke-WmiMethod -Path $_.__Path –Name Terminate }

You can run it from powershell directly or from a ps1 if you've got your system setup. I detail unrestricted script setup on i kill zombies with powershell as well as other powershell tricks...