Thread: Help with system() function

  1. #1
    Registered User
    Join Date
    Mar 2009
    Posts
    5

    Help with system() function

    Hello ppl,

    I want to know if the system function can be used to run certain program like xcopy which are in the system32 directory in XP.

    Say for example will this work,
    system("xcopy d1 d2 /A");

    Is there any other function available which can do the same task, basically what I want is a function which can run certain programs in the system32 directory from the c program.


    Please help,
    Regards,
    Anjali

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    system will run programs in the systm32 directory if the path is set up to contain system32 - which is normally the case.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Mar 2009
    Posts
    5
    But is there any other way to do the same thing, i mean using other functions ??

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by anju.kap2r View Post
    But is there any other way to do the same thing, i mean using other functions ??
    Sure. What do you actually want to do? If you explain what you are trying to do, we can give you an idea of how to do it.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  5. #5
    Registered User
    Join Date
    Mar 2009
    Posts
    5
    Well I am just trying to execute certain DOS commands in a C program using the system() function. I wanted to know if there is any other function to do the same task

  6. #6
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Yes there is. If you tell is what you want to do differently from how system works, then we can tell you which one to use. There is no point me suggesting one or three different ones, since they are all quite a bit harder to use than system, and all have their own advantages and disadvantages.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  7. #7
    Registered User
    Join Date
    Mar 2009
    Posts
    5
    okay so system("xcopy d1 d2 /A"); would work fine ??

  8. #8
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by anju.kap2r View Post
    okay so system("xcopy d1 d2 /A"); would work fine ??
    Yes.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  9. #9
    Registered User
    Join Date
    Mar 2009
    Posts
    5
    Thanks a lot Mats

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 05-13-2011, 08:28 AM
  2. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  3. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  4. measuring system resources used by a function
    By Aran in forum C Programming
    Replies: 1
    Last Post: 03-13-2006, 05:35 PM
  5. I need help with passing pointers in function calls
    By vien_mti in forum C Programming
    Replies: 3
    Last Post: 04-24-2002, 10:00 AM