I wanted to determine the command-line arguments of a running process at the Command Prompt (cmd.exe
).
E.g., if I started my abc.exe
program as follows:
abc -d
I want to determine the whole command line later. The TASKLIST
utility does not provide this info, because it just reports the exe name and not the arguments with which the process was started.
Here is a GUI-based method (Tested on Windows 7 - YMMV). I don't know of an easy method to get this data from the command-line.
- Open the Task Manager (CTRL+SHIFT+ESC), and go to the Processes tab.
- From the View menu -> Select Columns...
- Scroll to the very bottom and select "Command Line"
- In the newly-shown "Command Line" column, you can see the entire command that started the process, including any command-line parameters
Command-line method:
- Start a PowerShell with administrator priviledges
Use the Get-WmiObject to list processes and filter the process name above. Add/remove fields through the select statement below - example:
Get-WmiObject win32_process -Filter "name like '%notepad.exe'"|select CreationDate,ProcessId,CommandLine|ft -AutoSize
Note: The process name "notepad.exe" is used for this example, substitute the name for your specific scenario.
the method from mellanmokb works acutally, but i think the question whould be? can i see in in code maybe, if that is the case, are you using C# o VB?.
If the case is C# you can see it in msdn library
There you can see that the arguments arrives at the Main(string[] args), and this is a string that you can read as argument = args[i] with i the number of the argument you want
for example if you call args[2] on the commandline was text.exe test here there
args[2] will be here.
remmember that args[i] is a string always.
hope this helped