views:

137

answers:

2

A program for which I do not have the source code to is executing a third-party EXE file. I'd like to find out the arguments that it is sending to the EXE file (i.e. thirdparty.exe -c "foo" -d "bar"). I do know that the initial program is written in Visual Basic.

Are there any tools that I can run that will monitor the execution call and intercept the arguments?

Any help would be appreciated.

+3  A: 

To get it programmatically, use WMI:

SelectQuery query = new SelectQuery("select CommandLine from Win32_Process where Name='thirdparty.exe'");
ManagementObjectSearcher searcher = new ManagementObjectSearcher(query);
foreach (var process in searcher.Get())
{
  Debug.WriteLine(process.GetPropertyValue("CommandLine"));
}

If you just want to see the command line, you can do so using Process Explorer.

itowlson
+1 for Process Explorer
leoluk
+1  A: 

Use Image File Execution Options. By setting a registry key appropriately, you can have the OS execute the executable of your choice (instead of thirdparty.exe), allowing you to transform the parameters and run thirdparty.exe on those yourself, if that is what you need. The middle program will likely not even know the difference.

Moron