Thread: Executing system command

  1. #1
    Unregistered
    Guest

    Question Executing system command

    Say I want to run a program in C:\program files\my folder\program.exe

    This has spaces in it so when I try to do:

    system("C:\program files\my folder\program.exe");

    it cannot find the path. What can I do to fix this?

  2. #2
    Evil Member
    Join Date
    Jan 2002
    Posts
    638
    You gotta escape slashes.

    use \\ instead of just \.

    Also, relying on LFN is generally bad. reduce the lenght of the directory names, or use XXXXXX~1 notation.

  3. #3
    Registered User matheo917's Avatar
    Join Date
    Sep 2001
    Posts
    279
    depending of your compiler you might have to use slash (/)

    or a double back slash to neutralize the first one (\\)

    Regards,
    matheo917

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Using variables within system command?
    By moagim in forum C++ Programming
    Replies: 22
    Last Post: 10-09-2006, 10:42 AM
  2. Executing system commands cross platform
    By markucd in forum C++ Programming
    Replies: 6
    Last Post: 11-04-2005, 08:56 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, 07:43 AM
  5. IDEA: Customizeable command system
    By Inquirer in forum Contests Board
    Replies: 1
    Last Post: 10-02-2002, 10:17 PM