Using Windows' command line shell to open files and folders
Launching files and folders from the Command prompt
Section titled “Launching files and folders from the Command prompt”The following has only been tested on Windows XP.
Current directory structure
Section titled “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.html30/03/2004 12:04 AM <DIR> css29/03/2004 06:57 PM <DIR> CVS30/03/2004 12:04 AM <DIR> ent30/03/2004 12:04 AM 1,406 favicon.ico30/03/2004 12:04 AM <DIR> images30/03/2004 12:04 AM 3,916 index.html30/03/2004 12:04 AM <DIR> kb29/03/2004 06:59 PM 940 Makefile30/03/2004 12:04 AM 113 robots.txt30/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
Section titled “Open a folder into a new Explorer window”We can open the kb directory using the command
start kbOpening a file with its associated program
Section titled “Opening a file with its associated program”Open index.html with the default web browser by typing its name in the DOS prompt.
index.htmlUsing cygwin
Section titled “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/htmlReferences
Section titled “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.