WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

User Sample Code

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Get Commandline Parameters from Any Process

 Keywords: retrieving get command line commandline params  parameters EXE process application

Question:

Does anyone have a technique for retrieving the command line parameters (if any) that a running process was started with?

Answer:

If you can assume at least Windows XP there is always the WMI Win32_Process class's 'CommandLine' property
Run('Notepad.exe', 'Testing 1 2 3')
objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
colProcesses = objWMIService.ExecQuery( "Select * from Win32_Process Where Name = 'Notepad.exe'")
ForEach objProcess In colProcesses
    strCommandLine = objProcess.CommandLine
    Message("NotePad Command Line", strCommandLine)
Next

Article ID:   W18480
Filename:   Get Commandline Parameters from Any Process.txt
File Created: 2008:12:15:08:13:32
Last Updated: 2008:12:15:08:13:32