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. Argument to System() with space in the path

Argument to System() with space in the path

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
6 Posts 4 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.
  • A Offline
    A Offline
    Andraw111
    wrote on last edited by
    #1

    Hi, dear all, I have a license check exe file with only one argument. CString exe = getCurrentProjectPath(); //e.g, C:\Temp CString pwd = "12345" CString exeString = exe + " \"" + pwd + "\""; system(exeString); everything works fines with above codes. But if I put double quota between exe, I get "filename, .... syntext is incorrect". CString exeString = "\"" + exe + "\" \"" + pwd + "\""; But if I don't put exe data in a quota, if the path has space, it also cannot work. How should I solve this issue? Thanks!

    Richard Andrew x64R A 2 Replies Last reply
    0
    • A Andraw111

      Hi, dear all, I have a license check exe file with only one argument. CString exe = getCurrentProjectPath(); //e.g, C:\Temp CString pwd = "12345" CString exeString = exe + " \"" + pwd + "\""; system(exeString); everything works fines with above codes. But if I put double quota between exe, I get "filename, .... syntext is incorrect". CString exeString = "\"" + exe + "\" \"" + pwd + "\""; But if I don't put exe data in a quota, if the path has space, it also cannot work. How should I solve this issue? Thanks!

      Richard Andrew x64R Offline
      Richard Andrew x64R Offline
      Richard Andrew x64
      wrote on last edited by
      #2

      CString exeString = (CString)"\"" + exe + (CString)"\" \"" + pwd + (CString)"\"";

      EDIT: Added space between quotes.

      The difficult we do right away... ...the impossible takes slightly longer.

      A 1 Reply Last reply
      0
      • A Andraw111

        Hi, dear all, I have a license check exe file with only one argument. CString exe = getCurrentProjectPath(); //e.g, C:\Temp CString pwd = "12345" CString exeString = exe + " \"" + pwd + "\""; system(exeString); everything works fines with above codes. But if I put double quota between exe, I get "filename, .... syntext is incorrect". CString exeString = "\"" + exe + "\" \"" + pwd + "\""; But if I don't put exe data in a quota, if the path has space, it also cannot work. How should I solve this issue? Thanks!

        A Offline
        A Offline
        Andraw111
        wrote on last edited by
        #3

        It is solved, thanks!

        J 1 Reply Last reply
        0
        • Richard Andrew x64R Richard Andrew x64

          CString exeString = (CString)"\"" + exe + (CString)"\" \"" + pwd + (CString)"\"";

          EDIT: Added space between quotes.

          The difficult we do right away... ...the impossible takes slightly longer.

          A Offline
          A Offline
          Andraw111
          wrote on last edited by
          #4

          Richard, thanks for your reply. I try using double quota around all the arguments, not work. If you have multiple arguments that all are in double quota, you need to use "call". The following line works fine. CString exeString = "call \"" + exe + "\" \"" + pwd + "\"".

          L 1 Reply Last reply
          0
          • A Andraw111

            Richard, thanks for your reply. I try using double quota around all the arguments, not work. If you have multiple arguments that all are in double quota, you need to use "call". The following line works fine. CString exeString = "call \"" + exe + "\" \"" + pwd + "\"".

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            You might find it better to use one of the exec()[^] functions.

            One of these days I'm going to think of a really clever signature.

            1 Reply Last reply
            0
            • A Andraw111

              It is solved, thanks!

              J Offline
              J Offline
              Joan M
              wrote on last edited by
              #6

              Then you should change the subject on your question and put a SOLVED at the end or at the beginning. And it would be nice that you would put the answer/solution there too. ;)

              [www.tamautomation.com] Robots, CNC and PLC machines for grinding and polishing.

              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