<--- Turn the page
   
(contents page)
   
Turn the page ---> Shape Up Your DOS Command Environment |
DOS PROMPT: What does your DOS prompt look like? Does it tell you what drive you are on? What directory you are in? How about what time it is? Would you like it to? If we don't set the PROMPT environment variable to anything, DOS prints the following line as the DOS prompt: A>The A denoting disk drive A (or if a C, drive C) and a greater-than sign. We would like it to display the current directory (or path) also. So let us create a PROMT string. First let us put the following two commands as the PROMPT: PROMPT $p$gThis will now display the following as the prompt when you are in the root directory of drive C: C:\>How about the in the TEMP directory: C:\TEMP>Now, we could add some text: PROMPT The current path is: $p$gdisplays: The current path is: C:\TEMP>How about the date and time: PROMPT $d$:t$_The current path is: $p$gdisplays: Sun 01-01-1998: 1:23:45.67 The current path is: C:\TEMP>What if you don't want to display the hundredths-of-seconds of the time: PROMPT $d$:t$h$h$_The current path is: $p$gdisplays: Sun 01-01-1998: 1:23:45 The current path is: C:\TEMP>The following table lists the meta-strings and their meanings: $_ Carriage return/line feed $b Vertical pipe char $d Date $t Time $e The Esc Char $g The greater-than sign (>) $l The less-than sign (<) $h Moves the cursor back one space $n Current Disk drive name $p Current drive and path $q An equal sign (=) $v DOS version $$ A dollar sign ($) To have DOS display your wanted prompt each time DOS is loaded, you can put the following line in your AUTOEXEC.BAT file (editing it to your wants): PROMPT $d$:t$h$h$_The current path is: $p$g Also see Page 8 on how to change the color of the DOS Prompt and other DOS screens. DOSKey: Do you use DOSKey? For those of you who don't, DOSKey allows you to enter commands at the DOS prompt faster and easier. DOSKey allows command recall and the use of macros. At the DOS prompt enter: DOSKEYYour DOS prompt should now look like this: C:\>DOSKEY DOSKey Installed.This means the DOSKey was installed correctly. Now let us entry a few commands. First, clear the screen: CLSNext get the version number of DOS/Windoze: VERNow get the volume of the disk: VOLNone of those commands had anything to do with this article. However, let us now do the following at the DOS prompt: Hit the UP ARROW key. What is on the command line? VOL. How about the UP ARROW again: VER. Hit the ENTER KEY. It is as if you entered the command VER yourself. |
Now hit the the F7 key. DOSKey displays: 1: CLS 2: VER 3: VOL 4: VERWhich command do you want to run? Let us clear the screen. Hit F9 and DOSKey askes the following: C:\> Line number:Now hit 1 and the ENTER KEY. DOSKey puts CLS on the prompt line. Now press ENTER again. What if you enter a long command line at the dos prompt: APROG /parm1=1 /parm2=1 /parm3=0 /parm4=1Now you want to enter the exact command line but you need to change parm2=1 to parm2=0. Hit the UP ARROW. Now hit the RIGHT ARROW key a few times. Notice you can move along the command line as if it where in a text editor. Now hold the CTRL key down and hit the RIGHT ARROW. Just as in most DOS editors, the cursor jumps to the next word. Now move to the 1 at the end of parm2=. Let us change it to 0. If you enter 0, DOSKey replaces the 1. If you wanted to change it to 10, you will notice that the rest of the parm list does not move to allow room for the extra digit of the 10. Just hit the INSERT key and press the 0. Then hit the INSERT key to turn it off. As with EDIT.COM and other editors, pressing END or HOME will move the cursor to the end or start of the command line respectively. Also, if you press the ESC key, DOSKey will clear the command line. What about those macros? As stated before, DOSKey allows macros for faster processing of multiple command lines and/or commands. For instance. Let us say that we want to clear the screen (CLS), get the version (VER), and get the volume everytime we enter DOS. Excluding batch files, this is what we can do to save time and key punching. At the DOS prompt (assuming you have already loaded DOSKey), enter the following: DOSKEY CLSVV=CLS $T VER $T VOLThis line created a macro with a name CLSVV. Now all we have to do is enter CLSVV at the DOS prompt and DOSKey will do the rest for us. You probably noticed the $T in the macro defination above. This command tells DOSKey that the next command is a seperate command, not a parameter of the current command. Here are a few more commands DOSKey allows in macro definations: $1, $2, $3, ... are used like %1, %2, %3 in batch files. $G (or $g) is the greater-than sign for redirection (&h62;) $L (or $l) is the less-than sign for redirection (&h60;) $B (or $b) is the pipe sign for redirection (&h124;) To view what macros you have installed, enter the following at the DOS prompt: DOSKEY /M Now how to save these macros for next time you enter DOS. Enter the following at the DOS prompt to save all macros you have installed. DOSKEY /M &h62; MACDEF.BATNow you can edit and add macro definitions so that if you call this batch file from AUTOEXEC.BAT after the installation of DOSKey line, all of these macros will be defined. If you have been following this article pretty closely, you should have a MACDEF.BAT file that contains the following lines of text: CLSVV=CLS $T VER $T VOLNow edit this batch file and add DOSKEY to the beginning of this line. You can also add more lines. To save typing, enter: DOSKEY CPB=COPY /B $1 $2This macro will allow you to copy two files with the /binary attribute by only typing: CPB file1.ext file2.extMake sure that your PATH environment variable points to the directory the MACDEF.BAT resides or move MACDEF.BAT to a directory that PATH can find and add the following lines to your AUTOEXEC.BAT file: REM The following line loads DOSKey DOSKEY REM The following line calls the batch file to define all of our macros MACDEFNow everytime you load DOS, DOSKey will load and have all the macro definitions defined in MACDEF.BAT. And remember, you can always edit MACDEF to add/delete/modify macros. ¥ |
<--- Turn the page
   
(contents page)
   
Turn the page ---> Page 3