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 / C++ / MFC
  4. ::ShellExecute - Problem passing arguments

::ShellExecute - Problem passing arguments

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
13 Posts 6 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.
  • P PankajB

    Hi there. I have an Console based Exe (ABC.exe) that takes some parameters. Now, I want to call this Exe from some other application and want to pass the paremeters as required. Problems: 1. I am calling this exe as below

    HINSTANCE hInst = ::ShellExecute(NULL, L"open", L"C:\\Documents and Settings\\pankaj.bhalla\\Desktop\\ABC.exe", L"Hello", NULL, SW_SHOW);

    ABC.exe application got launched but text "Hello" never got displayed on the console. 2. In place of this hardcoded text i.e., "Hello", incase I want to send some text stored in CString type variable then how can I do that. Help will be really appretiated. Thanks PanB

    C Offline
    C Offline
    Cedric Moonen
    wrote on last edited by
    #4

    PankajB wrote:

    ABC.exe application got launched but text "Hello" never got displayed on the console.

    Why would it be displayed on the console ? Are you retrieving it in the code of your application and prining the argument ? If yes, it's the argument at index 1, and not 0 that you have to use (the first argument is always the path to your application).

    PankajB wrote:

    In place of this hardcoded text i.e., "Hello", incase I want to send some text stored in CString type variable then how can I do that.

    Just pass the CString object.

    Cédric Moonen Software developer
    Charting control [v2.0] OpenGL game tutorial in C++

    1 Reply Last reply
    0
    • P PankajB

      Hi there. I have an Console based Exe (ABC.exe) that takes some parameters. Now, I want to call this Exe from some other application and want to pass the paremeters as required. Problems: 1. I am calling this exe as below

      HINSTANCE hInst = ::ShellExecute(NULL, L"open", L"C:\\Documents and Settings\\pankaj.bhalla\\Desktop\\ABC.exe", L"Hello", NULL, SW_SHOW);

      ABC.exe application got launched but text "Hello" never got displayed on the console. 2. In place of this hardcoded text i.e., "Hello", incase I want to send some text stored in CString type variable then how can I do that. Help will be really appretiated. Thanks PanB

      C Offline
      C Offline
      CPallini
      wrote on last edited by
      #5

      Does your ABC.exe application correctly print it's first argument if launched by command line? :)

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
      [My articles]

      1 Reply Last reply
      0
      • P PankajB

        I am basically passing a path to a file. Target application just check whether file exists, if does not then create that file.

        R Offline
        R Offline
        Rajesh R Subramanian
        wrote on last edited by
        #6

        PankajB wrote:

        Target application just check whether file exists, if does not then create that file.

        You can as well create the file from the calling application as well. Why are you needing to have an executable solely for this? Or is there anything else? If the file copying takes too long and that leaves you with a frozen UI, just spawn a thread. Can't you? You haven't answered my question: Is the target application handling the command line passed on to it? Without that being done, how will it display the command line?

        It is a crappy thing, but it's life -^ Carlo Pallini

        1 Reply Last reply
        0
        • P PankajB

          Hi there. I have an Console based Exe (ABC.exe) that takes some parameters. Now, I want to call this Exe from some other application and want to pass the paremeters as required. Problems: 1. I am calling this exe as below

          HINSTANCE hInst = ::ShellExecute(NULL, L"open", L"C:\\Documents and Settings\\pankaj.bhalla\\Desktop\\ABC.exe", L"Hello", NULL, SW_SHOW);

          ABC.exe application got launched but text "Hello" never got displayed on the console. 2. In place of this hardcoded text i.e., "Hello", incase I want to send some text stored in CString type variable then how can I do that. Help will be really appretiated. Thanks PanB

          P Offline
          P Offline
          PankajB
          wrote on last edited by
          #7

          Let me provide few details... 1. Lets say ABC.exe just cout the text provided as an argument. 2. If I launch ABC.exe from console, >ABC.exe Hello, it prints out Hello on the Screen. 3. if I call the same application like HINSTANCE hInst = ::ShellExecute(NULL, L"open", L"C:\\Documents and Settings\\pankaj.bhalla\\Desktop\\ABC.exe", L"Hello", NULL, SW_SHOW); ...it does not Just FYI, ABC.exe is a Console based Application

          M R C 3 Replies Last reply
          0
          • P PankajB

            Let me provide few details... 1. Lets say ABC.exe just cout the text provided as an argument. 2. If I launch ABC.exe from console, >ABC.exe Hello, it prints out Hello on the Screen. 3. if I call the same application like HINSTANCE hInst = ::ShellExecute(NULL, L"open", L"C:\\Documents and Settings\\pankaj.bhalla\\Desktop\\ABC.exe", L"Hello", NULL, SW_SHOW); ...it does not Just FYI, ABC.exe is a Console based Application

            M Offline
            M Offline
            Michael Schubert
            wrote on last edited by
            #8

            Is the calling application also a console app? If not, does it open a new console window?

            1 Reply Last reply
            0
            • P PankajB

              Let me provide few details... 1. Lets say ABC.exe just cout the text provided as an argument. 2. If I launch ABC.exe from console, >ABC.exe Hello, it prints out Hello on the Screen. 3. if I call the same application like HINSTANCE hInst = ::ShellExecute(NULL, L"open", L"C:\\Documents and Settings\\pankaj.bhalla\\Desktop\\ABC.exe", L"Hello", NULL, SW_SHOW); ...it does not Just FYI, ABC.exe is a Console based Application

              R Offline
              R Offline
              Rajesh R Subramanian
              wrote on last edited by
              #9

              You must show us the target application's code, where you've handled the command line passed on to it.

              It is a crappy thing, but it's life -^ Carlo Pallini

              1 Reply Last reply
              0
              • P PankajB

                Let me provide few details... 1. Lets say ABC.exe just cout the text provided as an argument. 2. If I launch ABC.exe from console, >ABC.exe Hello, it prints out Hello on the Screen. 3. if I call the same application like HINSTANCE hInst = ::ShellExecute(NULL, L"open", L"C:\\Documents and Settings\\pankaj.bhalla\\Desktop\\ABC.exe", L"Hello", NULL, SW_SHOW); ...it does not Just FYI, ABC.exe is a Console based Application

                C Offline
                C Offline
                CPallini
                wrote on last edited by
                #10

                HINSTANCE hInst = ::ShellExecute(NULL, L"open", L"C:\\Documents and Settings\\carlo.pallini\\ABC.exe", L"Hello", NULL, SW_SHOW);

                works fine with my ABC.exe app... :rolleyes:

                If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                [My articles]

                M 1 Reply Last reply
                0
                • C CPallini

                  HINSTANCE hInst = ::ShellExecute(NULL, L"open", L"C:\\Documents and Settings\\carlo.pallini\\ABC.exe", L"Hello", NULL, SW_SHOW);

                  works fine with my ABC.exe app... :rolleyes:

                  If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                  This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                  [My articles]

                  M Offline
                  M Offline
                  Michael Schubert
                  wrote on last edited by
                  #11

                  CPallini wrote:

                  works fine with my ABC.exe app...

                  You must have the final release. I tried it with Beta 3 of abc.exe and the output was "Get lost" instead of "Hello"...

                  C 1 Reply Last reply
                  0
                  • M Michael Schubert

                    CPallini wrote:

                    works fine with my ABC.exe app...

                    You must have the final release. I tried it with Beta 3 of abc.exe and the output was "Get lost" instead of "Hello"...

                    C Offline
                    C Offline
                    CPallini
                    wrote on last edited by
                    #12

                    :-D

                    If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                    This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                    [My articles]

                    1 Reply Last reply
                    0
                    • P PankajB

                      Hi there. I have an Console based Exe (ABC.exe) that takes some parameters. Now, I want to call this Exe from some other application and want to pass the paremeters as required. Problems: 1. I am calling this exe as below

                      HINSTANCE hInst = ::ShellExecute(NULL, L"open", L"C:\\Documents and Settings\\pankaj.bhalla\\Desktop\\ABC.exe", L"Hello", NULL, SW_SHOW);

                      ABC.exe application got launched but text "Hello" never got displayed on the console. 2. In place of this hardcoded text i.e., "Hello", incase I want to send some text stored in CString type variable then how can I do that. Help will be really appretiated. Thanks PanB

                      D Offline
                      D Offline
                      David Crow
                      wrote on last edited by
                      #13

                      PankajB wrote:

                      ABC.exe application got launched but text "Hello" never got displayed on the console.

                      Does the console window open at all?

                      "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

                      "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                      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