Help on System Command

This is a discussion on Help on System Command within the C++ Programming forums, part of the General Programming Boards category; system ("\"C:\Documents and Settings\All Users\Desktop\Aitorg\org\3.bat\""); What is wrong with this command that it doesent get executed.??...

  1. #1
    Registered User
    Join Date
    Nov 2005
    Posts
    28

    Help on System Command

    system ("\"C:\\Documents and Settings\\All Users\\Desktop\\Aitorg\\org\\3.bat\"");

    What is wrong with this command that it doesent get executed.??

  2. #2
    Rabble Rouser Slacker's Avatar
    Join Date
    Dec 2005
    Posts
    116
    >What is wrong with this command that it doesent get executed.??
    What does the console tell you when you try to run it? Do you get an error or does it just not do anything? Does it hang, or seem to skip the call entirely? What does the following print?
    Code:
    cout << system ( 0 ) << '\n';

  3. #3
    Registered User
    Join Date
    Nov 2005
    Posts
    28
    IT says cannot find the path 'C:\Documents
    it is strange it worked before but when i tryed it now it doesnt (i mean the same code) i had to replace it with c:\docu~1\alluse~1\.....
    WHY THAT?!

  4. #4
    Hardware Engineer
    Join Date
    Sep 2001
    Posts
    1,398
    It's the nested quotes.... What you see as nested quotes, the computer sees as two pair of quotes. (A backslash in quotes, some more text, and then another set of quotes with nothing inside.)

    You do need quotes around the folder names and filenames with spaces... I'm not sure about long filenames. Maybe filenames longer than the 8.3 DOS limit need quotes too. In any case, one set of quotes should do it.

  5. #5
    Registered User
    Join Date
    Jan 2005
    Posts
    7,317
    >> It's the nested quotes.... What you see as nested quotes, the computer sees as two pair of quotes.
    I don't think so. The \" is a single quote, since you must use that escape character to add a quote inside your string. So "\"Hello\"" in code is just "Hello" on the other end.

    Maybe system just cannot handle long filenames. Also consider trying:

    system ("\"C:\\Documents and Settings\\All Users\\Desktop\\Aitorg\\org\\\"3.bat");

  6. #6
    Registered User ~Kyo~'s Avatar
    Join Date
    Jun 2004
    Posts
    319
    I will assume this is windows based in which case you can do this instead:
    Code:
    system ("C:\\Documents and Settings\\All Users\\Desktop\\Aitorg\\org\\3.bat");
    Also in some post I did a while back you can use either / or \\ its just a matter of preferance.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. system command not executing with format specifier
    By ridhamshah in forum C Programming
    Replies: 6
    Last Post: 11-08-2006, 04:58 AM
  2. Getting System(); Command to Return Value
    By Mellowz in forum C Programming
    Replies: 6
    Last Post: 01-13-2006, 12:44 AM
  3. Problem using system() command.
    By mmongoose in forum C++ Programming
    Replies: 2
    Last Post: 08-20-2005, 08:44 PM
  4. System() command opens a dos-box
    By phil_drew in forum Windows Programming
    Replies: 2
    Last Post: 03-16-2004, 06:43 AM
  5. IDEA: Customizeable command system
    By Inquirer in forum Contests Board
    Replies: 1
    Last Post: 10-02-2002, 10:17 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21