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. Executing a program with arguments

Executing a program with arguments

Scheduled Pinned Locked Moved C / C++ / MFC
adobequestionhelp
6 Posts 3 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.
  • N Offline
    N Offline
    Nicolas Bonamy
    wrote on last edited by
    #1

    Hello, I am trying launching an application telling it to open a document. I build a command line surrounding the program name and each document with quotes and then use ShellExec to process. This works fine with all applications except old Adobe programs (like PhotoDeluxe or Photoshop LE). So I tried CreateProcess instead it does not work either. Tried ShellExecuteEx same error: the program does not find the document. If I take the command line I am builing and paste it in a Command Prompt it works. Other programs are able to run the application passing it a file to open. So my question is: what other way can I use to run that application telling it to open an application... Should I revert to _exec or is there something else? Regards, Nicolas

    D 1 Reply Last reply
    0
    • N Nicolas Bonamy

      Hello, I am trying launching an application telling it to open a document. I build a command line surrounding the program name and each document with quotes and then use ShellExec to process. This works fine with all applications except old Adobe programs (like PhotoDeluxe or Photoshop LE). So I tried CreateProcess instead it does not work either. Tried ShellExecuteEx same error: the program does not find the document. If I take the command line I am builing and paste it in a Command Prompt it works. Other programs are able to run the application passing it a file to open. So my question is: what other way can I use to run that application telling it to open an application... Should I revert to _exec or is there something else? Regards, Nicolas

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

      What does the code snippet look like that tries to launch Adobe and its command-line arguments?


      Five birds are sitting on a fence. Three of them decide to fly off. How many are left?

      N 1 Reply Last reply
      0
      • D David Crow

        What does the code snippet look like that tries to launch Adobe and its command-line arguments?


        Five birds are sitting on a fence. Three of them decide to fly off. How many are left?

        N Offline
        N Offline
        Nicolas Bonamy
        wrote on last edited by
        #3

        Something like this: // build arguments string fnames; list sel = GetSelection(); for (list::iterator it = sel.begin(); it != sel.end(); ++it)     fnames += "\"" + *it + "\" "; // quotes strEditor = "\"" + strEditor + "\""; strDir= "\"" + strDir+ "\""; // run the app ShellExecute(NULL, "open", strEditor.c_str(), fnames.c_str(), strDir.c_str()); This works with latest version of Photoshop for instance (6 and later) and Paint Shop Pro but NOT with Photoshop LE 5 and Photoshop Deluxe. CreateProcess and ShellExecuteEx fail the same way: the app is correctly launched but it can't find the files I am passing. Regards, Nicolas

        D 1 Reply Last reply
        0
        • N Nicolas Bonamy

          Something like this: // build arguments string fnames; list sel = GetSelection(); for (list::iterator it = sel.begin(); it != sel.end(); ++it)     fnames += "\"" + *it + "\" "; // quotes strEditor = "\"" + strEditor + "\""; strDir= "\"" + strDir+ "\""; // run the app ShellExecute(NULL, "open", strEditor.c_str(), fnames.c_str(), strDir.c_str()); This works with latest version of Photoshop for instance (6 and later) and Paint Shop Pro but NOT with Photoshop LE 5 and Photoshop Deluxe. CreateProcess and ShellExecuteEx fail the same way: the app is correctly launched but it can't find the files I am passing. Regards, Nicolas

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

          Have you tried calling ShellExecute() with string constants instead of variables? This will tell you if the variables are incorrect. ShellExecute(NULL, "open", "c:\\program files\\adobe.exe", "file1 c:\\somepath\\file2 file3", "c:\\somedir", ...);


          Five birds are sitting on a fence. Three of them decide to fly off. How many are left?

          N L 2 Replies Last reply
          0
          • D David Crow

            Have you tried calling ShellExecute() with string constants instead of variables? This will tell you if the variables are incorrect. ShellExecute(NULL, "open", "c:\\program files\\adobe.exe", "file1 c:\\somepath\\file2 file3", "c:\\somedir", ...);


            Five birds are sitting on a fence. Three of them decide to fly off. How many are left?

            N Offline
            N Offline
            Nicolas Bonamy
            wrote on last edited by
            #5

            David, thanks for suggesting. The problem came from the trailing whitespace at the end of fnames. I removed it and it workls! Thanks again, Nicolas

            1 Reply Last reply
            0
            • D David Crow

              Have you tried calling ShellExecute() with string constants instead of variables? This will tell you if the variables are incorrect. ShellExecute(NULL, "open", "c:\\program files\\adobe.exe", "file1 c:\\somepath\\file2 file3", "c:\\somedir", ...);


              Five birds are sitting on a fence. Three of them decide to fly off. How many are left?

              L Offline
              L Offline
              l a u r e n
              wrote on last edited by
              #6

              nothing like hardcoding stuff for testing huh? :)


              "there is no spoon"
              biz stuff   about me

              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