Thread: how to run dos command programatically

  1. #1
    Registered User
    Join Date
    Nov 2002
    Posts
    117

    how to run dos command programatically

    how to run dos command by programming??
    is there any examlpes?

    thank you for helping.

  2. #2
    Registered User moi's Avatar
    Join Date
    Jul 2002
    Posts
    946
    look up system()
    hello, internet!

  3. #3
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Try reading the FAQ
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  4. #4
    Registered User
    Join Date
    Nov 2002
    Posts
    117

    how to look up??

    i am a new comer .......could you please tell me more about that?

    thank you so much

  5. #5
    Use system(). If I wanted to use the command "cd C:\WINDOWS" I would use system() like-
    Code:
    system("cd C:\WINDOWS\")
    and it would change the current directory to C:\WINDOWS\.

  6. #6
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231

    Re: how to look up??

    Originally posted by Jasonymk
    i am a new comer .......could you please tell me more about that?

    thank you so much
    More than how to follow a link?

    >>system("cd C:\WINDOWS\")
    Not very useful, in practical terms. It doesn't change the current working directory.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  7. #7
    Registered User
    Join Date
    Nov 2002
    Posts
    117

    i got it!!

    thank you so much!!

  8. #8
    Registered User
    Join Date
    Nov 2002
    Posts
    117

    what should be the project type?

    whne i build a new project for it, what should i made?
    win 32 console application?

  9. #9
    If you want it to be ran in the MS-DOS window then yes.

  10. #10
    Registered User
    Join Date
    Nov 2002
    Posts
    117

    cant back to c:\

    i have made a program as below:

    Code:
     /* 
    #include <stdlib.h>
    
    int main(void)
    { 
        system("cmd.exe");	
        return 0;
    }
    
    */
    the output is a comand prompt but not cmd.exe, but with the tilte testing.exe(testing, which is my project name), and i cant use system() to go back to c:/

    what should i do?

  11. #11
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    >what should i do?
    Explain what you are trying to do, think it through thuroughly, and try again
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  12. #12
    Registered User
    Join Date
    Nov 2002
    Posts
    117

    ok...what i am trying to do is......

    at the beginning , i wanna start a acrobat distiller with c++, but is seems too difficult for me, then i found that i can use dos command to start the distiller in the dos prompt.

    what i am trying to do is to write a program, which is used to start the distiller, and so serveral operations automatically once the program being ran.

    and first i would like to try out out to use C++ to control the dos prompt. but fail.

    for example, how to generate a dos prompt(cmd.exe) from a program?
    i cant do so in the program i have post before, is ti because i have use the win32 console application?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Re-doing a C program to run in Win2000 or XP
    By fifi in forum C Programming
    Replies: 5
    Last Post: 08-17-2007, 05:32 PM
  2. Compiling a program in VC++ and run it in DOS
    By Willhunting in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 01-18-2003, 04:09 AM
  3. how to use system to run more than 1 dos command?
    By Jasonymk in forum C++ Programming
    Replies: 10
    Last Post: 01-03-2003, 12:01 AM
  4. DOS screen output 'containment'
    By Unimatrix139 in forum A Brief History of Cprogramming.com
    Replies: 10
    Last Post: 12-19-2002, 04:08 AM
  5. Dos programming Concept problem.
    By L.O.K. in forum A Brief History of Cprogramming.com
    Replies: 9
    Last Post: 12-17-2002, 03:25 AM