How to use the Windows command line shell to open files and folders
The following has only been tested on Windows XP.
1. Current directory structure
Those familiar with DOS will know that previously, only .bat, .com and .exe could be executed. However, its 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.
3. How to open a file with its associated program
Open the index.html with the default web browser by typing its name in the DOS prompt.
index.html
4. 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 $
5. 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.

