none
'File name' is not recognized as an internal or external command, operable program or batch file?

    Question

  • Hello there,

    I previously had the problem that I couldn't compile a simple code program, which has been solved, but now I'm having this problem that after I compile it (using cl /EHsc 'file name'.cpp) and I type in the name of the file it comes up with :

    'File name' is not recognized as an internal or external command, operable program or batch file.

    I've checked that the file is in the right directory and it is, so I'm not sure what the problem is.

    I would be grateful if someone would get back to me regarding this problem.

    Many thanks,

    John Holland.

     

    Tuesday, July 27, 2010 8:30 AM

Answers

  • I have set the directory to C:\Users\John\My Documents and in that directory are the three folders:

    1. the C++ source

    2. the application

    3. the object file

    All of which are different versions of the 'basic' file.

    Whenever I try and compile them I get the error message that it doesn't recognise the program of batch file.

    I'm using the cl /EHsc command to compile the program and convert it into an .exe file so that I can type in the word and the sentence will hopefully come up.

    Is there anything wrong with what I'm doing? Or is it something to do with the fact that I'm using Windows 7 Home Premium?

    Many thanks,

    John.


    The .exe file needs to be in the current directory. If it's in a sub-folder, then you either need to use that in the path, example:

    .\sub-folder\basic.exe

    or CD to the sub-folder and then run basic.exe.


    http://blog.voidnish.com
    Tuesday, July 27, 2010 8:08 PM
    Moderator

All replies

  • What is the name of the executable and in which path does it reside?

    What is it that you're typing to execute it?

     


    «_Superman_»
    Microsoft MVP (Visual C++)
    Tuesday, July 27, 2010 8:32 AM
  • Hi John,

    you are likely to get a quicker answer if you include all the relevant information, in this case the exact command line you are entering; otherwise we have to guess something which may be obvious to you.

    In this case, I guess that you are typing 'filename.cpp' on your command line and getting that response.  This is because source code (such as .cpp files) is not executable in itself; it's the reason you have to compile and link, and the result of these operations is an executable with a .exe suffix.  Look in your current folder for something named 'filename.exe' and try that instead.


    Answering policy: see profile.
    Tuesday, July 27, 2010 8:39 AM
  • In this case I saved the file as  'basic.cpp' in C:\Users\John\My Documents

    Then I typed in cl /EHsc basic.cpp to compile the program.

    Finally, when I typed in the word 'basic' to bring up the code, it came up with the error message:-

    'basic.cpp' is not recognized as an internal or external command, operable program or batch file.

    Many thanks,

    John.

    Tuesday, July 27, 2010 7:20 PM
  • In this case I saved the file as  'basic.cpp' in C:\Users\John\My Documents

    Then I typed in cl /EHsc basic.cpp to compile the program.

    Finally, when I typed in the word 'basic' to bring up the code, it came up with the error message:-

    'basic.cpp' is not recognized as an internal or external command, operable program or batch file.

    Many thanks,

    John.


    When you run cl basic.cpp, basic.exe is generated in the current directory (which may be different from My Documents). So you may need to copy it to My Documents if you plan on running it from there.

     


    http://blog.voidnish.com
    Tuesday, July 27, 2010 7:32 PM
    Moderator
  • I checked in my documents and I have three different versions of the 'basic' file

    1. the C++ source

    2. the application

    3. the object file.

    Are these all the file types needed to run the file? I thought they were.

    Many thanks,

    John.

    Tuesday, July 27, 2010 7:55 PM
  • I checked in my documents and I have three different versions of the 'basic' file

    1. the C++ source

    2. the application

    3. the object file.

    Are these all the file types needed to run the file? I thought they were.

    Many thanks,

    John.

    No, you only need the .exe file. To run it, you need to be in that folder (in the command prompt). If you are not, then use the cd command to change the current directory to that folder.

    http://blog.voidnish.com
    Tuesday, July 27, 2010 7:57 PM
    Moderator
  • I have set the directory to C:\Users\John\My Documents and in that directory are the three folders:

    1. the C++ source

    2. the application

    3. the object file

    All of which are different versions of the 'basic' file.

    Whenever I try and compile them I get the error message that it doesn't recognise the program of batch file.

    I'm using the cl /EHsc command to compile the program and convert it into an .exe file so that I can type in the word and the sentence will hopefully come up.

    Is there anything wrong with what I'm doing? Or is it something to do with the fact that I'm using Windows 7 Home Premium?

    Many thanks,

    John.

    Tuesday, July 27, 2010 8:02 PM
  • I have set the directory to C:\Users\John\My Documents and in that directory are the three folders:

    1. the C++ source

    2. the application

    3. the object file

    All of which are different versions of the 'basic' file.

    Whenever I try and compile them I get the error message that it doesn't recognise the program of batch file.

    I'm using the cl /EHsc command to compile the program and convert it into an .exe file so that I can type in the word and the sentence will hopefully come up.

    Is there anything wrong with what I'm doing? Or is it something to do with the fact that I'm using Windows 7 Home Premium?

    Many thanks,

    John.


    The .exe file needs to be in the current directory. If it's in a sub-folder, then you either need to use that in the path, example:

    .\sub-folder\basic.exe

    or CD to the sub-folder and then run basic.exe.


    http://blog.voidnish.com
    Tuesday, July 27, 2010 8:08 PM
    Moderator
  • Thank you very much. Problem solved!

    John.

    Tuesday, July 27, 2010 8:25 PM
  • hi john

    how did you solved that problem, i am also stuck over it. Whenever i compile my code, an error comes which says "the system cannot find the file specified" where the file is nameOfTheProject.exe, and when i check mannualy i dont see any exe file on the specified path, in debug in my case

    what should i do to solve this issue?

    Anshul 

    Sunday, June 01, 2014 7:49 PM