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 directory of the file.
Opening a file without a space or quotes opens the file in VLC as expected.
How can I get around this?
Adding the initial "" as Glen indicated ensures CMD continues and does not enter wait mode. This is particularly important in a batch file.
In summary:
1- Open file and wait for user to close it before proceeding to next command
2- Open file and continue to next command (without waiting)
Depending on your need you might opt for 1 or 2.
I suspect start does something special when the first char of the first argument is a quote. The first argument is a window title, and the second is the command/file to open
http://ss64.com/nt/start.html
It is a well known problem (at least for me :-)
You will have to use a short name format in your
CMD
script. To find out a short name for a particular file do the following:CMD
window pointing to the file's folder.$> dir /X
Hope, it helps
Just leave off
start
, and surround the full filename (including any path) with double-quotes. This works fine on my system: