shellwindows-7command-line

Opening file with spaces in Windows via Command Prompt


I want to open a file (particularly video files) in its default program via script. When I come across a file name with spaces, it is taken as several arguments which was no surprise:

  C:\folder>start test space.avi
  The system cannot find the file test.

However, when I surround the file name with quotes:

  C:\folder>start "test space.avi"

Instead of opening the file in its default program (VLC), a new Command Prompt window is opened up to the file's directory.

Opening a file without a space or quotes opens the file in VLC as expected.

How can I get around this?


Solution

  • Just leave off start, and surround the full filename (including any path) with double-quotes. This works fine on my system:

    C:\>"test space.avi"