25

I'm in E:\blah\blah but I need to run an .exe from E:\folder name\prgm.exe

However, I am trying to call this without having to do cd ..

I read that just typing E:\folder name\prgm.exe should work. However when I try this I get an error:

E:\folder is not recognized as an external or internal command.

I'm running Windows 7 if that helps.

3 Answers 3

28

E:\folder name\prgm.exe works if the folder name has no space in it.

Either:

  1. Rename the folder so it has no space.
  2. Use quotes. (e.g. "E:\folder name\prgm.exe")
  3. Or add E:\folder name to the path.

Use option 3) if it is an often used program.
Use option 2) for single or rare invokations.

2
  • Thank you! I had originally tried moving it into a folder without a space, but it wasn't working since the command required an input file argument, for which I was forgetting the E:\... in front of that as well. I couldn't do the quotes since i was running this command from MATLAB which itself required quotes for syntax purposes. Thank you again!
    – Bob
    Oct 20, 2012 at 1:38
  • Thank you for reminding me to add the folder to the path
    – Jim Lahman
    Jul 29, 2021 at 21:30
12

The reason that you get the error

E:\folder is not recognized as an external or internal command.

is because the system thinks that your folder name is "folder" since what is after the space would be a place to put a flag such as -t or -l . Whenever you have a space in the name of a file or a folder (not really a good practice, you can use a - or an _ to separate words in the name) you should use double quotation marks around the entire name, this includes the filename and its extension. If there is a flag or an option to the command it would have to be outside of the quotation marks example, from you blah blah folder

E:\blah\blah>"E:\folder name\prgm.exe" -t -l 1000
3
  • 1
    This is really a comment and not an answer to the original question. To critique or request clarification from an author, leave a comment below their post - you can always comment on your own posts, and once you have sufficient reputation you will be able to comment on any post. Please read Why do I need 50 reputation to comment? What can I do instead?
    – DavidPostill
    Feb 6, 2016 at 22:06
  • 3
    That was my first intention but due to a low number of rep points I couldn't comment, that's why I had to write a reply.
    – nassim
    Feb 21, 2016 at 15:50
  • 1
    I understand why you did it. But please don't do that.
    – DavidPostill
    Feb 21, 2016 at 16:47
6

Just for completeness' sake, I would like to note that in addition to Hennes' answer, there is a fourth option, though in fact you might find it too similar to cd:

Enter pushd E:\folder name and your working directory changes to the specified drive and folder (no quotes required) in one easy step; returning to the previous working directory is a no-brainer as well with a simple popd

1
  • This solved my problem (thanks mousio) pushd %~dp0, then ... execute whatever, then popd
    – arkod
    Apr 22, 2015 at 12:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.