Thread: opening files

  1. #1
    Banned
    Join Date
    Oct 2004
    Posts
    250

    opening files

    system("FarCry.exe");
    wont start fracry unless its in the same folder is there any other way to start a program outside the folder the .exe is in?

  2. #2
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,820
    Put the path of the exe in the system call
    Woop?

  3. #3
    Registered User caroundw5h's Avatar
    Join Date
    Oct 2003
    Posts
    751
    Having said said, you should also be aware of the options and pitfalls
    Warning: Opinions subject to change without notice

    The C Library Reference Guide
    Understand the fundamentals
    Then have some more fun

  4. #4
    Banned
    Join Date
    Oct 2004
    Posts
    250
    it still does not work, it compiles allright but when i try and run it, it does not open the file i added system("pause"); to see what was wrong 'C://Docuaments' is not recognized as an internal or external command
    operable program or batch file.
    does anyone know how to fix this
    Code:
    #include <iostream>
    using namespace std;
    int main()
    {
        system("C:\\Docuaments And Settings\\wmorrish\\destop\\a.txt");
        system("pause");
    }
    Last edited by cgod; 10-18-2004 at 11:39 PM.

  5. #5
    Registered User
    Join Date
    Sep 2004
    Posts
    719
    maybe if you learned to spell you wouldn't have that problem
    i seem to have GCC 3.3.4
    But how do i start it?
    I dont have a menu for it or anything.

  6. #6
    Banned
    Join Date
    Oct 2004
    Posts
    250
    yeah..
    i fixed the spelling error but im still getting the same 'C://Documents' is not recognized as an internal or external command
    operable program or batch file

  7. #7
    VA National Guard The Brain's Avatar
    Join Date
    May 2004
    Location
    Manassas, VA USA
    Posts
    903
    you are using the forward slash in your path instead of the backward slash.
    • "Problem Solving C++, The Object of Programming" -Walter Savitch
    • "Data Structures and Other Objects using C++" -Walter Savitch
    • "Assembly Language for Intel-Based Computers" -Kip Irvine
    • "Programming Windows, 5th edition" -Charles Petzold
    • "Visual C++ MFC Programming by Example" -John E. Swanke
    • "Network Programming Windows" -Jones/Ohlund
    • "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
    • "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel

  8. #8
    Banned
    Join Date
    Oct 2004
    Posts
    250
    i tired backward slash to. could someone write an example system("file");
    with path so i can see

  9. #9
    ---
    Join Date
    May 2004
    Posts
    1,379
    i just tried this

    Code:
    #include <stdlib.h>
    
    int main(void)
    {
      system("D:\\fasm\\fasmw.exe");
      system("pause");
      return 0; 
    }
    and it works fine
    Last edited by sand_man; 10-19-2004 at 07:49 AM.

  10. #10
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Maybe system() only works with the 8.3 filename format. Try
    "c:\\docume~1\\wmorrish\\desktop\\a.txt"
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  11. #11
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,817
    Just trying to do a system("whatever.txt") command isn't going to do anything right? It would probably say something like "invalid command or filename". Shouldn't it be more along the lines of system("notepad.exe whatever.txt") or you can maybe use the ShellExecute function? You can run things like EXEs that way but to open something like a document requires a little bit more.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  12. #12
    Banned
    Join Date
    Oct 2004
    Posts
    250
    wow thanks the
    Code:
    "c:\\docume~1\\wmorrish\\desktop\\a.txt"
    worked what does the docume~1 mean?

  13. #13
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    wow... first you want to copy a program, then you want to restart the system and now you want to run another program using the system call... maybe you could instead write a program to write a batch file or registry key and turn off (possibly crash?) the computer so whenever somebody turns it back on, your batch file/registry key runs a program that then does whatever it wants
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

  14. #14
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    >>what does the docume~1 mean?
    It's how a filename or path is represented when the actual filename exceeds 8 characters. If you have "asdfasdf" it will just be "asdfasdf", but if you have "asdfasdffdsafdsa" then it will be "asdfas~1".
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Opening ASCII files in C?
    By Mavix in forum C Programming
    Replies: 6
    Last Post: 04-25-2007, 02:23 PM
  2. Need help opening a series of files
    By ramparts in forum C Programming
    Replies: 9
    Last Post: 11-14-2006, 05:49 PM
  3. Opening files with UNICODE file names
    By decohk in forum Linux Programming
    Replies: 2
    Last Post: 11-09-2006, 05:25 AM
  4. opening files
    By angelic79 in forum C Programming
    Replies: 3
    Last Post: 10-19-2004, 06:52 AM
  5. Opening files - Giving options?
    By wwwGazUKcom in forum C++ Programming
    Replies: 3
    Last Post: 09-18-2001, 07:06 AM