The Computer Oracle

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

--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Hypnotic Puzzle4

--

Chapters
00:00 How Do I Find Out Command Line Arguments Of A Running Program?
00:17 Accepted Answer Score 100
00:28 Answer 2 Score 128
00:49 Answer 3 Score 12
01:17 Answer 4 Score 68
02:09 Thank you

--

Full question
https://superuser.com/questions/415360/h...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#windows7 #windows #commandlinearguments

#avk47



ANSWER 1

Score 128


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



ACCEPTED ANSWER

Score 100


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




ANSWER 3

Score 68


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.




ANSWER 4

Score 12


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...