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. DOS Commands

DOS Commands

Scheduled Pinned Locked Moved C / C++ / MFC
c++sysadminhelptutorial
9 Posts 7 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.
  • C Offline
    C Offline
    cberam
    wrote on last edited by
    #1

    Hi, How to execute DOS commands in MFC. I use WinExec() to use COPY commands. It works fine to copy files to local directory/system. But it fails to copy file to another PC in the network. WinExec("cmd /c copy Prints.txt \\avon\Prints",SW_SHOW); \\avon is the network PC with shared folder Prints This commands works filke from DOS prompt but not from MFC..Pls help Ram

    R R K L D 6 Replies Last reply
    0
    • C cberam

      Hi, How to execute DOS commands in MFC. I use WinExec() to use COPY commands. It works fine to copy files to local directory/system. But it fails to copy file to another PC in the network. WinExec("cmd /c copy Prints.txt \\avon\Prints",SW_SHOW); \\avon is the network PC with shared folder Prints This commands works filke from DOS prompt but not from MFC..Pls help Ram

      R Offline
      R Offline
      Russell
      wrote on last edited by
      #2

      Try using ShellExecute (or ShellExecuteEx)

      Russell

      C 1 Reply Last reply
      0
      • C cberam

        Hi, How to execute DOS commands in MFC. I use WinExec() to use COPY commands. It works fine to copy files to local directory/system. But it fails to copy file to another PC in the network. WinExec("cmd /c copy Prints.txt \\avon\Prints",SW_SHOW); \\avon is the network PC with shared folder Prints This commands works filke from DOS prompt but not from MFC..Pls help Ram

        R Offline
        R Offline
        Rage
        wrote on last edited by
        #3

        What is wrong with CopyFile, or CFile::Copy ? Why going to DOS if using MFC ? ~RaGE();

        1 Reply Last reply
        0
        • R Russell

          Try using ShellExecute (or ShellExecuteEx)

          Russell

          C Offline
          C Offline
          cberam
          wrote on last edited by
          #4

          Thanks for reply.Can you pls give me an example?

          R 1 Reply Last reply
          0
          • C cberam

            Hi, How to execute DOS commands in MFC. I use WinExec() to use COPY commands. It works fine to copy files to local directory/system. But it fails to copy file to another PC in the network. WinExec("cmd /c copy Prints.txt \\avon\Prints",SW_SHOW); \\avon is the network PC with shared folder Prints This commands works filke from DOS prompt but not from MFC..Pls help Ram

            K Offline
            K Offline
            kakan
            wrote on last edited by
            #5

            cberam wrote:

            \\avon\Prints

            Try \\\\avon\\Prints

            1 Reply Last reply
            0
            • C cberam

              Thanks for reply.Can you pls give me an example?

              R Offline
              R Offline
              Russell
              wrote on last edited by
              #6

              If the DOS command that you wrote was working,... then you can use something like: ShellExecute(NULL, "cmd.exe", "/c copy Prints.txt \\avon\Prints"); (WinExec is an old function, and it is possible that it isn't a good interface between your app and DOS)

              Russell

              1 Reply Last reply
              0
              • C cberam

                Hi, How to execute DOS commands in MFC. I use WinExec() to use COPY commands. It works fine to copy files to local directory/system. But it fails to copy file to another PC in the network. WinExec("cmd /c copy Prints.txt \\avon\Prints",SW_SHOW); \\avon is the network PC with shared folder Prints This commands works filke from DOS prompt but not from MFC..Pls help Ram

                L Offline
                L Offline
                Laxman Auti
                wrote on last edited by
                #7

                cberam wrote:

                How to execute DOS commands in MFC. I use WinExec() to use COPY commands. It works fine to copy files to local directory/system. But it fails to copy file to another PC in the network. WinExec("cmd /c copy Prints.txt \\avon\Prints",SW_SHOW); \\avon is the network PC with shared folder Prints

                Have a try with system API

                system("copy c:\\test.txt \\\\Test\\mydata");

                Knock out 't' from can't, You can if you think you can :cool:

                1 Reply Last reply
                0
                • C cberam

                  Hi, How to execute DOS commands in MFC. I use WinExec() to use COPY commands. It works fine to copy files to local directory/system. But it fails to copy file to another PC in the network. WinExec("cmd /c copy Prints.txt \\avon\Prints",SW_SHOW); \\avon is the network PC with shared folder Prints This commands works filke from DOS prompt but not from MFC..Pls help Ram

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

                  Most DOS commands have a Win32 API equivalent (e.g., CopyFile()). Use that instead.


                  "The largest fire starts but with the smallest spark." - David Crow

                  1 Reply Last reply
                  0
                  • C cberam

                    Hi, How to execute DOS commands in MFC. I use WinExec() to use COPY commands. It works fine to copy files to local directory/system. But it fails to copy file to another PC in the network. WinExec("cmd /c copy Prints.txt \\avon\Prints",SW_SHOW); \\avon is the network PC with shared folder Prints This commands works filke from DOS prompt but not from MFC..Pls help Ram

                    T Offline
                    T Offline
                    ThatsAlok
                    wrote on last edited by
                    #9

                    cberam wrote:

                    It works fine to copy files to local directory/system. But it fails to copy file to another PC in the network.

                    What about using Direct CopyFile api!

                    "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

                    cheers, Alok Gupta VC Forum Q&A :- I/ IV

                    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