Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Get the command line parameters of an external process.

Get the command line parameters of an external process.

Scheduled Pinned Locked Moved C#
csharpc++helptutorial
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Matt Philmon
    wrote on last edited by
    #1

    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

    G 1 Reply Last reply
    0
    • M Matt Philmon

      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

      G Offline
      G Offline
      Guinness4Strength
      wrote on last edited by
      #2

      Did you ever figure this out ?

      M 1 Reply Last reply
      0
      • G Guinness4Strength

        Did you ever figure this out ?

        M Offline
        M Offline
        Matt Philmon
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups