26

I'm tried to run a command line something like this: start /max C:\Program files\foo\ba.exe -somearguments.

But I have a problem, the cmd returns an error message something like The system cannot found the C:\Program file and if I put the C:\Program files\foo\ba.exe around quotes, it simply run a new window cmd in MAX mode and don't run the program.

How to fix this?

0

4 Answers 4

19

All filenames and paths which contain spaces must be quoted.

Next, regarding your question, how about stating the path like:

start /max /d"C:\Program files\foo\" ba.exe -somearguments
1
  • 3
    This answer is only a partial solution: It will work if there are spaces in the path but it will not work if there are spaces in the filename. Calling ''start "b a.exe" fails.''
    – Georg W.
    Sep 18, 2018 at 13:19
18

The error happened because the system interpreted your command as the file C:\Program and file as an argument of your command. Obviously it doesn't find the file Program and returned this error.

To fix it, just include "" on the path between the words with the space character or on entire path:

start /max C:\"Program files"\foo\ba.exe -somearguments

or

start /max "C:\Program files\foo\ba.exe" -somearguments
7
  • There needs to be a "" before program path in the second example; see superuser.com/a/239572/1686 on why. Jun 5, 2012 at 17:13
  • You say I must include it? Ive just tested here now and it worked without "" before...
    – Diogo
    Jun 5, 2012 at 17:16
  • It might have changed, then, but cmd.exe on Windows XP would require it. Jun 5, 2012 at 17:43
  • I've just tried it, and Windows 7 definitely doesn't accept the second example, although the first one works. Jun 6, 2012 at 2:16
  • 2
    And kudos to the person at MicroSoft that decided to use a space in the folder name! Oct 2, 2016 at 22:41
6

Although wrapping the path in quotes is the easiest and clearest to read, you can also use the old DOS short names (since DOS followed 8.3 naming, file names longer than 8 characters were truncated with ~1) for files. These names do not have spaces. You can see the short names for files with the DIR /X command.

1
  • I needed a command line to launch conemu from atom text editor inside windows 10. This was the only method that would work for me in that case.
    – Thom Ives
    Jan 1, 2020 at 1:09
3

In Win10 you can try this:

start /max C:\Program%20files\foo\ba.exe -somearguments
1
  • 1
    Welcome to Super User! Can you explain what you are suggesting? :)
    – bertieb
    May 4, 2018 at 13:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .