Return to Tutorials Index
Return to CDP Main Index
CMD.exe is a Windows program which provides a command line interface to the rest of the system. This program contains a number of in-built commands such as dir, del, copy etc. One can also use it to type in commands which run other programs, such as the command line programs of the CDP System. The program is normally found in C:\Windows\System32 and if you are going to use it frequently, a desktop shortcut is recommended.
One of the basic things to understand about this interface is that it needs to know, as it were, where it is., i.e., which part of the hard drive it is accessing and onto which it is going to place new or altered files. The key concept is that of current directory. This is where it is now. Let's look at some terminology:
- top level
- this refers to the entire partition of a hard disk, conventionally named c:, d:. etc. When this is where the command prompt is, the command line of the prompt will read: c:\> In this notation, the c: means which partition, the '\' is a level marker and the '>' is pointing to the active cursor (should be flashing). All commands for this command interface are placed adjacent to this '>', without a space. When it says 'c:\' you know it's the top level because there's nothing to the left of the '\' except the 'c:'.
- this is a user-defined section of the hard drive. It's a logical section, meaning that the information may be physically scattered, but linked in software under this one label. These are like the drawers of a filing cabinet and are used in the same way: to group information in some sensible way.
- this is a user-defined directory inside another directory, such as ye olde manilla folders which we place inside the drawers of our filing cabinet.
- and what do we have inside the drawers or manilla folders? Files, usually documents. On the computer, these can be text files of various kinds such as plain ascii text or the text created by a word processor (which has extra, hidden formatting instructions); the files can also be executable programs, i.e., sets of instructions to do something. There is a special kind of file called a batch file; these have the extension '.bat' on Windows systems, and '.sh' on MAC and Linux conputers. They are text files which can contain commands (i.e., a list of command lines) and will execute all the commands in the list when run. The batch file is run by entering its name without the extension except on the MAC, where the extension is used.
- current directory
- this is literally where you are at any given time, i.e., the directory which is currently active. All new files will automatically be placed here unless explicitly told to do otherwise. The computer can access all files in the current directory without any further instructions about where it is. But, and this is vitally important, it cannot access any files outside of the current directory without being told where they are.
- 'path' is the mechanism by which the computer is told where something is. This can be done explicitly by typing this information on the command line. For example, the command:
will copy 'myfile.txt' from the directory 'somewhereelse' to the current directory 'hereiam'. Why the two dots? To go there and get this file, the computer had to go out of 'hereiam' (back up one level) and then across to 'somewhereelse'. The '..\' notation is how the computer does this. It is called 'going up a level'. In this case, both of these directories are directly under c:, the top level. The path to executable programs, and only to executable programs can be set to work automatically by setting the path command in Control Panel (see RUNNING THE CDP SYSTEM Setting the Path)
Files on the 'top level'
Files can be placed on the top level of a partition. If this is the case, they are simply on e.g. c:\ and not within a directory or sub-directory. To do something with a text file, you have to use a command such as copy or del(ete) or type and a command to do this would look like this:
NB1: It is assumed that you will press the ENTER key in order to run the command you've just put on the command line.
NB2: there is no space after the '\', but there is a space after the command 'type'; otherwise it would appear that the command were 'typeafile.txt', which it wouldn't recognise, resulting in the message 'bad command or filename'.
To do something with an executable file, i.e. a program or batch file, you just enter its name on the command prompt, omitting its extension '.exe' or .bat'. This would look like this:
The command dir lists all the files in the current directory, giving name, size, date and time it was saved, etc.
To go 'down' directory levels
This procedure uses the command cd, i.e., 'change directory' or, 'make the following the new current directory'. I could create a directory called 'drawer1' with the command md thus:
This places a directory inside the 'top level' of drive c:. I can then go there with the command cd thus:
Now, when I next see the Command Prompt, it will show:
Note that the '>' is now to the right of 'drawer1', showing that the path now includes 'drawer1'. This means that 'drawer1' is the current directory, and this is where you are now.
The computer will not find executable programs or any other files outside of this directory unless a path has been set or it is explicitly told where that file is.
To move to a sub-directory, such as ye olde manilla folder inside the drawer, you just continue the process. Thus, to move from 'drawer1 to 'manilla1' inside the drawer, you will enter:
and now the command prompt will look like this:
To go 'up' directory levels
Going back up uses the notation '..' or, more explicitly, '..\'. One set of the two dots moves you out of one directory back 'up' to the next adjacent higher level, i.e., the directory your current directory is inside of. 'Manilla1' is inside 'drawer1'. So to move out of 'manilla1' and up into 'drawer1', you enter:
and the command prompt will now look like this:
So you see what's happened. Similarly, moving back up to the top level can be done like this:
and the command prompt will say:
Finally, this move from a sub-directory to the top level (two levels up) can be done in one step:
Etc. This procedure works for any number of levels of 'nested' directories: up to whatever the system can handle. (Having too many levels of nesting can become both confusing and tedious.)
Setting the path with a batch file
The normal thing to do is to add the Path to the CDP programs (executables) to the PC system path, found under:
Control Panel > System (Properties) > Advanced (or Advanced System Properties) > Environment Variables
In the LOWER window, select the Path line and click Edit. Put a semi-colon (';') after the last entry and then add the CDP programs path. This should be: [drive-letter]:\cdpr7\_cdp\_cdprogs
The computer will now be able to access any .exe from anywhere, i.e., from whatever directory is the current one. This is because this path command instructs the computer to search the paths in turn to find the .exe being invoked.
You can also set a local, customised path within your current directory. Just write the path you want into a .bat file of any name (I use ae.bat) and run the batch file: enter the 'ae' on the command line with or without the '.bat' extension and press the ENTER key.
What can the command line interpreter do?
Enter the command help and you will be shown a list of all available commands. Note that you will probably be using only a handful of these! For specific help on a command, type help followed by the command name, for example help dir.
Detailed information on all CMD.exe commands can be found at the website ss64.com.
Return to Tutorials Index
Return to CDP Main Index
Last updated: 15 July 2016 (revised R. Fraser for Windows 7 and later)
© 1998-2016 Archer Endrich & CDP