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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Can VC++ launch MS Dos window then issues Dos commands? [modified]

Can VC++ launch MS Dos window then issues Dos commands? [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestion
23 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.
  • S Stephen Hewitt

    Can you describe your application a little. For example, is it a console application or a Win32 application?

    Steve

    A Offline
    A Offline
    ATC
    wrote on last edited by
    #14

    It is a WIN32 MFC application

    S 1 Reply Last reply
    0
    • A ATC

      It is a WIN32 MFC application

      S Offline
      S Offline
      Stephen Hewitt
      wrote on last edited by
      #15

      Try this: // DOSCommands.cpp : Defines the entry point for the application. //   #include "stdafx.h" #include <process.h> #include <conio.h>   int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { AllocConsole(); system("dir"); system("tree"); getch(); FreeConsole();   return 0; }

      Steve

      A 1 Reply Last reply
      0
      • S Stephen Hewitt

        Try this: // DOSCommands.cpp : Defines the entry point for the application. //   #include "stdafx.h" #include <process.h> #include <conio.h>   int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { AllocConsole(); system("dir"); system("tree"); getch(); FreeConsole();   return 0; }

        Steve

        A Offline
        A Offline
        ATC
        wrote on last edited by
        #16

        Once again you save my day, it works perfectly! Many thanks, I am really really appreciate it! :):-D:rolleyes:

        S 1 Reply Last reply
        0
        • A ATC

          Once again you save my day, it works perfectly! Many thanks, I am really really appreciate it! :):-D:rolleyes:

          S Offline
          S Offline
          Stephen Hewitt
          wrote on last edited by
          #17

          Glad I could help.

          Steve

          1 Reply Last reply
          0
          • A ATC

            I try ShellExecute(this->m_hWnd,"dir/k", "","","", SW_SHOW ); it does not work! Can you give a typical DOS command? Thanks

            S Offline
            S Offline
            Sam Hobbs
            wrote on last edited by
            #18

            Please stop saying DOS! First, did you search for previous answers? It is nearly certain that this question has been asked and answered many times before. When I said command shell, I meant command-interpreter. Look at the documentation of the system function. It is useful because it describes how the filename of the "command-interpreter file" is determined. For NT type versions of Windows, the command-interpreter file is Cmd.exe. For 95 versions of Windows, the command-interpreter file is Command.com. Those names might change for future version so it is better to get the filename from the environment. You need to execute the command-interpreter and pass the options and command on the command line. Note that this will create a new window for the command; if that is not what you need, then I am sorry for misleading you.

            S 1 Reply Last reply
            0
            • S Sam Hobbs

              Please stop saying DOS! First, did you search for previous answers? It is nearly certain that this question has been asked and answered many times before. When I said command shell, I meant command-interpreter. Look at the documentation of the system function. It is useful because it describes how the filename of the "command-interpreter file" is determined. For NT type versions of Windows, the command-interpreter file is Cmd.exe. For 95 versions of Windows, the command-interpreter file is Command.com. Those names might change for future version so it is better to get the filename from the environment. You need to execute the command-interpreter and pass the options and command on the command line. Note that this will create a new window for the command; if that is not what you need, then I am sorry for misleading you.

              S Offline
              S Offline
              Stephen Hewitt
              wrote on last edited by
              #19

              While you're correct you seem to be being a little pedantic; I think we both know what he meant by the question.

              Steve

              S 1 Reply Last reply
              0
              • S Stephen Hewitt

                While you're correct you seem to be being a little pedantic; I think we both know what he meant by the question.

                Steve

                S Offline
                S Offline
                Sam Hobbs
                wrote on last edited by
                #20

                I did not know what was meant by the initial question and the answer could have depended on the difference. People trying to help often waste their time answering a misunderstood question. People asking questions should try to be clear. In this situation, this person is not trying. It is now not important for this question, but this person will likely waste people's time in the future. My guess is that this person is not using the best solution for their fundamental problem. They probably think that this solution is the easiest, but then they will need to enhance it some more and the final solution is likely to be more work than if they considered all their requirements initially and asked for solutions for all the requirements.

                S 1 Reply Last reply
                0
                • S Sam Hobbs

                  I did not know what was meant by the initial question and the answer could have depended on the difference. People trying to help often waste their time answering a misunderstood question. People asking questions should try to be clear. In this situation, this person is not trying. It is now not important for this question, but this person will likely waste people's time in the future. My guess is that this person is not using the best solution for their fundamental problem. They probably think that this solution is the easiest, but then they will need to enhance it some more and the final solution is likely to be more work than if they considered all their requirements initially and asked for solutions for all the requirements.

                  S Offline
                  S Offline
                  Stephen Hewitt
                  wrote on last edited by
                  #21

                  I understood what he meant. Sometimes people do be vague and it annoyes me, but in this instance I didn't have any problems.

                  Steve

                  S 1 Reply Last reply
                  0
                  • S Stephen Hewitt

                    I understood what he meant. Sometimes people do be vague and it annoyes me, but in this instance I didn't have any problems.

                    Steve

                    S Offline
                    S Offline
                    Sam Hobbs
                    wrote on last edited by
                    #22

                    I have not been very active in CodeProject, but in the CodeGuru forums I was the first to hit 10,000 posts and about 99% of them were efforts to help others. So I have seen quite a few vague questions and such. People often spend less time asking a question than we spend answering them. In this situation, my guess is that there are better answers if the person were to take the time to be clear about requirements.

                    S 1 Reply Last reply
                    0
                    • S Sam Hobbs

                      I have not been very active in CodeProject, but in the CodeGuru forums I was the first to hit 10,000 posts and about 99% of them were efforts to help others. So I have seen quite a few vague questions and such. People often spend less time asking a question than we spend answering them. In this situation, my guess is that there are better answers if the person were to take the time to be clear about requirements.

                      S Offline
                      S Offline
                      Stephen Hewitt
                      wrote on last edited by
                      #23

                      I can't argue with you there.

                      Steve

                      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