Get the command line parameters of an external process.
-
Does anyone know how to get the commandline parameters of an externally created process? The Process class gives you the StartInfo property which includes "Arguments". This works great if I want to start my own process. However, I've found that it never contains the arguments used to start an external process that my program didn't start. It's always empty. In C, there's a Win32 call for GetCommandLine() which would work great... except it only works for the calling process, not an external one. SysInternals' "Process Explorer" does this without any trouble for any process so I know it can be done. Any help? I don't care if it's C/C++, VB, VB.NET, or C#. Thanks
-
Does anyone know how to get the commandline parameters of an externally created process? The Process class gives you the StartInfo property which includes "Arguments". This works great if I want to start my own process. However, I've found that it never contains the arguments used to start an external process that my program didn't start. It's always empty. In C, there's a Win32 call for GetCommandLine() which would work great... except it only works for the calling process, not an external one. SysInternals' "Process Explorer" does this without any trouble for any process so I know it can be done. Any help? I don't care if it's C/C++, VB, VB.NET, or C#. Thanks
Did you ever figure this out ?
-
Did you ever figure this out ?
Yeah, I ultimately did in C++. I wrote a wrapper in ATL COM so I could easily use it in a C# project I was working on at the time. Unfortunately the hard drive it existed on was lost when the project was shelved a couple years back. I MAY have a backup still on another drive at the office. I can dig that up for you if you really need it, but it will need to wait until Monday. If you can't, then look into examining the PEB (process environment block). I think it had something to do with NtQueryInformationProcess but I'm not sure. You can get the processID of the process you want to query with the .NET classes, then jump into the lower level API calls to get the rest. Hmmm, maybe there's an actual article in there for CP. I hadn't thought about that before.