Shell – open file with spaces in Windows by command prompt

I want to open a file (especially a video file) in its default program through a script. When I encounter a file name with spaces, it is treated as several parameters, This is not surprising:

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

However, when I enclose the file name in quotation marks:

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

not in its Open the file in the default program (VLC) and open a new command prompt window to the file directory.

Opening a file without spaces or quotation marks will open the file in VLC as expected.

< p>How can I bypass this?

Just leave the beginning and enclose the complete file name (including any path) in double quotes. This works fine on my system:

C:\>"test space.avi"

I want to open a file (especially a video file) in its default program through a script. When I encounter a file name with spaces, it is treated as several parameters, which is not surprising:

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

But when I enclose the file in quotation marks Name:

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

Instead of opening the file in its default program (VLC), open A new command prompt window to the file directory.

Opening a file without spaces or quotation marks will open the file in VLC as expected.

How can I bypass this?

Just leave the beginning and enclose the full file name (including any path) in double quotes. This works fine on my system:

C:\>"test space.avi"

Leave a Comment

Your email address will not be published.