running executables with system("ren ....")

This is a discussion on running executables with system("ren ....") within the C++ Programming forums, part of the General Programming Boards category; I want to run telnet from my program. That is, run the telnet service on the computer running the program, ...

  1. #1
    Unregistered Leeman_s's Avatar
    Join Date
    Oct 2001
    Posts
    753

    running executables with system("ren ....")

    I want to run telnet from my program. That is, run the telnet service on the computer running the program, not telnet as in using the telnet.

    If you double click tlntsvr.exe the telnet service starts up. If my programs runs, it does not.

    system("ren C:\\WINDOWS\\System32\tlntsvr.exe");

    There are no warnings or compile errors, anybody know why the line doesn't do the same thing as double-clicking the icon?

  2. #2
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    Maybe because the ren command renames a file?

  3. #3
    Unregistered Leeman_s's Avatar
    Join Date
    Oct 2001
    Posts
    753
    lol god am i stupid.

    well this didn't work anyhow:

    system("C:\\WINDOWS\\System32\tlntsvr.exe");

    is there another command im supposed to use?

  4. #4
    booyakasha
    Join Date
    Nov 2002
    Posts
    208
    Originally posted by Leeman_s
    lol god am i stupid.

    well this didn't work anyhow:

    system("C:\\WINDOWS\\System32\tlntsvr.exe");

    is there another command im supposed to use?
    Should you have two slashes after WINDOWS?

  5. #5
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Originally posted by beege31337
    Should you have two slashes after WINDOWS?
    In a standard string, you should always have two slashes in a row when you want to actually end up with one single slash in the line. The reason for this is that with characters and strings, the \ is considered an escape character. Once it sees that, it translates the following character into an escape sequence:

    \\ == one slash
    \n == new line
    \r == carriage return

    And so on...

    So, every \ should actually be two in that sequence, not just the first two. Alternately for paths you can just use the / instead of \\. In their case, the final "\t" turns into a tab instead of a backslash and the letter T.

    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Running hidden executables in background
    By Fender Bender in forum Windows Programming
    Replies: 15
    Last Post: 04-17-2005, 10:59 AM
  2. multithreading question
    By ichijoji in forum C++ Programming
    Replies: 7
    Last Post: 04-12-2005, 10:59 PM
  3. Question about running executables from program
    By PJYelton in forum C++ Programming
    Replies: 2
    Last Post: 03-19-2005, 03:43 PM
  4. running executables in c code
    By cathal in forum C Programming
    Replies: 2
    Last Post: 08-20-2004, 05:29 AM
  5. Warning to those running executables posted to the board
    By *ClownPimp* in forum C++ Programming
    Replies: 11
    Last Post: 04-03-2002, 07:48 PM

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