Tracing the arguments of an external .EXE called within a VB.net app
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 w开发者_运维技巧ill monitor the execution call and intercept the arguments?
Any help would be appreciated.
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.
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.
精彩评论