How to use Windows command-line commands in code

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • manontheedge
    New Member
    • Oct 2006
    • 175

    How to use Windows command-line commands in code

    In Windows, if you open a command prompt, there are a bunch of keywords like, 'chdir', 'copy', ...

    What I'm trying to figure out is how to use that COPY command in c++ code. I want to use the COPY command with the options (/a, /b, ...).

    How do I do this?

    Every time I search for this on Google, the results are no where close to what I'm looking for. Any help is appreciated.
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    Can you not just call system()?

    Comment

    • manontheedge
      New Member
      • Oct 2006
      • 175

      #3
      Ugh, yeah, that would be what I'm looking for. I apparently was trying to complicate things. Thank you.

      Comment

      • Banfa
        Recognized Expert Expert
        • Feb 2006
        • 9067

        #4
        Of course you could always call the WIN32 API function CopyFile.

        I personally would consider calling system to run a command that had a WIN32 API equivalent poor practice.

        Comment

        Working...