Launching files and folders from the Command prompt
The following has only been tested on Windows XP.
Current directory structure
Those familiar with DOS will know that previously, only .bat
, .com
and .exe
could be executed. However, it is
now possible to open and run any file using the Windows command shell that has a program associated with it.
This emulates the user opening the file from Window’s File Explorer.
For example, given the directory listing below (which contains a copy of this website):
D:\jurn\magicmonster.com\src\output\html>dir
Volume in drive D is Programs
Volume Serial Number is 366B-10EB
Directory of D:\jurn\magicmonster.com\src\output\html
30/03/2004 12:04 AM <DIR> .
30/03/2004 12:04 AM <DIR> ..
30/03/2004 12:04 AM 2,297 about.html
30/03/2004 12:04 AM <DIR> css
29/03/2004 06:57 PM <DIR> CVS
30/03/2004 12:04 AM <DIR> ent
30/03/2004 12:04 AM 1,406 favicon.ico
30/03/2004 12:04 AM <DIR> images
30/03/2004 12:04 AM 3,916 index.html
30/03/2004 12:04 AM <DIR> kb
29/03/2004 06:59 PM 940 Makefile
30/03/2004 12:04 AM 113 robots.txt
30/03/2004 12:04 AM <DIR> services
5 File(s) 8,672 bytes
8 Dir(s) 3,250,106,368 bytes free
D:\jurn\magicmonster.com\src\output\html>
We are able to do the following.
Open a folder into a new Explorer window
We can open the kb
directory using the command
start kb
How to open a file with its associated program
Open index.html
with the default web browser by typing its name in the DOS prompt.
index.html
Using cygwin
If you are writing scripts in Cygwin, you can access the Windows command shell, and then run the same commands
prefixed with a cmd /c
to achieve the same thing. e.g.
$ pwd
/cygdrive/d/jurn/magicmonster.com/src/output/html
jurn@brownfang ~/magicmonster.com/src/output/html
$ cmd /c index.html
jurn@brownfang ~/magicmonster.com/src/output/html
$ cmd /c start kb
jurn@brownfang ~/magicmonster.com/src/output/html
References
For a more detailed description of the commands, you can get help by using the help
command. You can get help
about most Windows standard command line tools using this.
help start
will describe what the start command does.
help cmd
will describe the options available when opening a new shell.