Internal DOS Commands





BREAK CD
CHDIR
CHCP CLS COPY CTTY
DATE DEL
ERASE
DIR MD
MKDIR
PATH PROMPT
RD
RMDIR
SET TIME TYPE VER VOL
VERIFY LOCK UNLOCK LOADHIGH EXIT TRUENAME



If you are a DOS novice just learning these commands I would recommend just scrolling down the screen and reading about them all. Just remember the important ones like: DIR, COPY, CD, and DEL. They will get you started.


DIR

This command gives a listing of most of the files and directories on a disk (Hard disk and floppy disk). In DOS 3.3 and below, there are only 2 known switches:
/W - gives the directory listing wide across your screen without times, dates, and sizes listed
/P - pauses the output of the DIR command if there are more files than can be listed on your screen at once

You can use these two switches interchangeably with no problems.

With DOS 5 and up you have MANY other switches you can use also. I hope to list them soon, although they don't do you much good.

UNDOCUMENTED: Use DIR followed by a comma to see EVERY file and directory, even if they're hidden! (Or have their SYSTEM attribute set).

C:\>DIR,

Use DIR followed by 3 or more periods to see ONLY files and directories WITHOUT any extension.

C:\>DIR....

These two tricks only work on DOS 5 to 6.22. They should work for DRDOS as well. To view hidden and system files under DOS 7 (Windoze 95) use "DIR /A"


TYPE

This command will dump the contents of a text file to your screen. Example:

C:\>type bill.txt
Bills stuff document.
Bill has 2 things:
1 basket ball
1 used sock
C:\>

This should mostly be used on plain ASCII text files. While you can use TYPE to print out an executable program to the screen, it will be a bunch of junk and you'll get a lot of annoying beeps. TYPE will stop printing a file to your screen when it encounters an End-Of-File character. This can come in handy if you want to keep something secret. I explain it on my SECRETS page. You can also get fancy and TYPE text files to things like your printer or Modem if you like.
C:\>type file.txt > lpt1
C:\>type upload.doc > com2

Note: With ALL versions of MSDOS and PCDOS you cannot use TYPE with wildcards (* and ?). BUT, under DRDOS 7 you can.


DEL and ERASE

DEL and ERASE do the exact same thing- why someone would type out ERASE every time they wanted delete a file is beyond me. You can use wild cards with either command without any problems. You can also use them in batch files easily.

TECH EXPLANATION: these commands don't destroy any data. They simply place the HEX character E5 (In HEX, E5 makes 1 ASCII character) as the first letter in the file's name and blank out that files place in the FAT. Don't confuse this with hiding a file - that has to do with the files attribute setting. The DIR command ignores any file it finds beginning with E5. If you delete a sensitive file on a diskette- but don't copy anything back to the disk or over write it- that document is still EASILY accessible. That's how UNDELETE and other utilities work. They DO look for files beginning with E5 (They also have to track down which clusters the file was stored on). If you don't have a program to over-write files, you can just copy a "safe" file of the SAME LENGTH over top of it.








MD and MKDIR
This lets you Make a Directory, hence the MD (MKDIR is a hold over from UNIX style OS's. If you switch between a UNIX OS and DOS, you may come to appreciate MKDIR). You type MD followed by a file name. You can nest (Make a directory within a directory) up to 16 directories on most DOS only systems (No Windoze). Some will let you nest up to 32. On windoze 95 machines you can get 3 lines of directories in a DOS box and 16 directories in MS-DOS mode. At this moment I really don't know where the limitation comes from, as it appears to be limited by the length of the command line. But I would think something other than the length of the command line would create the limitation (Like the FAT or something). The shorter the directory name the more you can nest. Anywho, it is good practice to separate your files and programs so everything is organized.












CD and CHDIR
This command lets you change directories. Lets say you are at root (Just a "C:\>" prompt) and you want to get into a directory named WINDOWS. Type the following:

C:\>cd windows
You will get a prompt like this:
C:\WINDOWS>

Now, wasn't that fun?! But wait, there's more! Oh know!! You need to get back to your root directory, and quick! Type "CD.." and you will be magically transported back to root. Ok, go back into any directory again. Now type DIR to see what is in there. You will notice that there are two sub directories, one called "." and the other called "..". They represent where you were and where you are. The "." is the directory you are in. ".." represents the parent directory, or the directory this directory is in (Confused yet?! Hang on, it'll get better the more you use it!). When you type "CD.." you are telling DOS to go to the directory you where just in. If you type "CD." nothing will happen since you are in that directory already. Pop quiz: what if you are about 7 directories in and you need to get to root? Instead of typing CD.. seven times in a row, use "CD\". Another trick; lets say that you are in your "C:\DOS>" directory and you want to get into "C:\GAMES\NES>"? Use this:

C:\DOS>cd \games\nes

You will be sent directly into your NES directory within your GAMES directory.


COPY

This command obviously copies files to different spots on your disks. It does not remove the source file after writing the new file. Usage:

C:\copy mystuff.doc A:

This example will copy "mystuff.doc" to your A: drive. Here's another example:

C:\copy mystuff.doc A:\stuff.doc

This copies "mystuff.doc" to the A: drive and renames it to "stuff.doc". Alright, say you want to combine two plain text files into one big happy file. This will accomplish that:

C:\copy mystuff.doc+herstuff.txt C:\house\ourstuff.yea

This combines "mystuff.doc" and "herstuff.txt" with the + symbol into one file named "ourstuff.yea" in the HOUSE directory. Any questions?
SWITCHES: /A /B /V

The switch /A treats a file like an ASCII text file. This means that if the file has an End-Of-File character in the middle of it everything up until the [E-O-F] character will be copied. Anything after that will be chopped off.
The switch /B treats the file like a binary file and will copy EVERY THING up the specified file length to the destination. If you have a an ASCII text file with an End Of File maker in the middle of it, copy will cut off every thing after the End Of File marker. Using the /B switch will ignore all control characters including End Of File markers. Example: if you try to TYPE the COMMAND.COM file to examine its contents, it stops early before you get to see anything interesting. Using the /B switch with copy we can see the ENTIRE thing.

COPY /B COMMAND.COM CON

This chain of commands sends, without interruption on End Of File control characters, the contents of COMMAND.COM to the CON device, which is your screen. It will beep a lot and take a long time to all go by, but you will be able to see all of its error messages and commands it will accept.

Switch /V makes COPY VERIFY if it correctly made a copy to the destination. I have never used this and I don't ever plan too. Unless you are tracking suspicious virus activity or you are dealing with bad media (Diskettes that are failing) you should never have to use /V.


RD and RMDIR
RD will Remove a Directory. Use RD followed by the name of the directory you wish to delete. You must empty the directory first or you will just get an error message from DOS. Since DOS 5.00 there has been a nifty utility called DELETREE which doesn't care if the directory has files in it.
























VER
VER will tell you what version of DOS you are using. If you happen to be stuck with widoz`95 VER will tell you some Windows version junk.

Undocumented: VER/R will tell you some more information like the revision letter and if DOS is in HIGH memory or not. Should work with DOS 5 on up.
























VOL
VOL will tell you the volume label of your hard drive or floppy disk. On DOS 5 and up it will also give you a serial number too. This can come in handy for batchfile programming if you need your INSTALL.BAT file to make sure the right disk is inserted in the disk drive.
























DATE
This command lets you set your systems date.

C:\>date
Current date is Wed 03-11-98
Enter new date (mm-dd-yy):
C:\>

You can just hit enter to not change it or you can specify a new system date. Not very complicated. It can also be used in a batchfile to log the date and/or time if some redirection is used.












TIME
This lets you set your systems time.

C:\time
Current time is 1:46:11.30p
Enter new time:
C:\>

You don't need to specify the time to the nearest millisecond like DOS displays it, an hour and a minute will do. Notice the p at the end of the second line. That means it's P.M. You MUST put a p at the end of your new time or else your computer will be set to A.M. You can put an a there if you want an A.M. time, or you can just leave it blank.
























PATH
The PATH is where DOS searches for programs. When you type the name of a program, like FORMAT, DOS will look through it's list of INTERNAL COMMANDs. Since FORMAT isn't an internal command DOS will then look through your current directory for that programs name. If it doesn't find FORMAT in your current directory it will look through all of the directories listed in your PATH environment variable. You can see what your current PATH is by just typing PATH. You can also see it by using SET, which lists ALL environment variables, of which PATH is one. Normally your AUTOEXEC.BAT file will set your PATH statement, but you can create or modify it at any time. Here's an example of how to view it:

C:\>path
PATH=C:\DOS;C:\WINDOWS;C:\UTIL;D:\GAMES;

C:\>

To change your path just use PATH followed by the new PATH directories. Notice the semi-colon between directories, this separates entries. The equal sign is optional when you are setting the PATH statement. Be careful, when you set the PATH you will replace the previous one. If you want to keep what is already there you will need the following batchfile, unless you retype the whole PATH string again.

@ECHO OFF
SET OLDPATH=%PATH%
SET PATH=%PATH%%1
SET OLDPATH=

You would use this as follows:

C:\>pathit.bat C:\BIN Where pathit.bat is your batchfiles name, and C:\BIN is the name of the directory you wish to add. This is how this batchfile works: First, it saves your current PATH as OLDPATH. Next it makes a new PATH starting with the old one, and then appends the directories you list on the command line to the end. There CANNOT be a space between the environment variable "%PATH%" and the command line switch "%1". You also need to know if a semi-colon is already at the end of your current PATH statement or not. If it is already there you can use the example as-is. If it ain't, you will either need to put one in the batchfiles second line, or add one before the path of the directory you are adding to your PATH. If you got lost with all this batchfile stuff you should visit my batchfile page. It will explain almost all of this.


CTTY
This cryptic and rarely used command can have some security value. It defines the device used to accept and display data (I.E. Your keyboard and monitor). If you set CTTY equal to the NULL device you must reset the computer in order to regain access. You can use it as the first line of your AUTOEXEC before it runs some sensitive programs that you don't want a user to CTRL+C out of. After you run the program or batch commands you can regain access to the system by having a CTTY CON statement at the end of your AUTOEXEC. Example:

CTTY NULL
COPY C:\WINDOWS\SECURE\*.INI C:\WINDOWS
ECHO Y|DEL C:\WINDOWS\TEMP\*.*
CTTY CON

Other values you can substitute for NULL are: AUX, PRN, COMx, LPTx, and maby some others I can't think of right now. The "x" in COMx and LPTx can be any valid number for your system: COM1, COM3, LPT1, ect.


BREAK
This lets you control extended error checking. "Duh, what the heck does that mean?" Well, if BREAK is ON it makes DOS check whether you are pressing CTRL+C or CTRL+BREAK more often than it normally would. On an older machine this may slow it down a bit too. To see if BREAK is ON or OFF just type BREAK at a command prompt.

C:\>break
BREAK is off

C:\>

You can turn BREAK on and off by using BREAK ON and BREAK OFF.























CLS
This command clears the screen. It also places your cursor at the top left-hand corner of your screen (Also called the "home position"). Got it?



















PROMPT
This is used to set your command prompt. If you use it by itself your prompt will change to C>. Your prompt looks like this most of the time:

C:\>

You can change it by typing PROMPT followed by any text that you want as your new prompt. There are also some switches you can add to spice up your boring old prompt.

$$ adds a $ to your prompt
$t states the time
$d states the date
$p lists your current directory and drive letter
$v adds your DOS version (Or Windoze 95 version)
$n lists just your current drive
$g the > character
$l the < character
$b the | character
$q the = character
$h a backspace, it deletes the last letter of your prompt
$e the escape character, can be A LOT of fun
$_ does a carriage return after listing your prompt

The most noteworthy of these are $P, $G, and $E. Just using $P$G will let you see your current path and have a > to separate your prompt from your commands. $E lets you enter escape sequences directly from a DOS prompt. You can set up key macros with it as well as change your background and foreground colors and move the cursor position.
You can also add control characters to your prompt. Using PROMPT ^A (Where ^A is CTRL+A) will make your DOS prompt a smiley face! Adding CTRL+G to your prompt will make your computer beep after every command you give DOS. Here's an example:

C:\>prompt $E[32m^A$E[33m$G$E[0m

ö>
ö>

This may look like a lot of gibberish, but you just have to break it down. $E[32m is an escape sequence that makes text green. ^A is CTRL+A (Our smiley face). $E[33m makes text orange, and $G makes a > appear after our smiley face. The last $E[0m resets the screen colors to the default (White on black).

MORE TO COME





CHCP
This is used to change the code page (Language, like Spanish or English) that your keyboard, screen, and printer use. I only know English and have never had to use this one. You must have the line COUNTRY=[path of country.sys file] in your config.sys file. You may also need to run NLSFUNC before you an use CHCP too. Type CHCP at your DOS prompt to see your current country code page, which is usually 437 or 850. Don't expect any more info on this one from me!

















SET
Set gives you control of environment settings. Environment settings are very handy in batchfile programming. One very well known environment setting is your PATH. To use it just type:

C:\>SET string1=string2

A decent example of use is listed under PATH. These strings can be letters, numbers, words, environment variables, and command line switches but ABSOLUTELY NO SPACES!!! (Visit my batchfile page for more on environment variables and command line switches-substitution). In our example string1 is the variable we are creating from scratch. String2 can be another "from scratch" variable or a preset variable like a command line switch or an already existent environment variable.


Well, that's all I have time for now, I'll get more examples for using set when I have time. Please feel free to email me if you need an answer.


VERIFY
This is more of an option rather than a command. When 'VERIFY' is turned on it double checks every file after it writes it. This helps to prevent corruption. If a file is written to a bad sector, VERIFY should detect it and relocate the file to a good part of the disk. The only drawback is that this will slow down write actions on a disk (Or diskette). I've played around a little with this, and found very little speed degradation with having VERIFY set to ON.

Typing just VERIFY will show you whether it is turned on or off. To set it just use VERIFY ON or VERIFY OFF respectively.













LOCK
This command is only available in DOS 7 for use with Windows 95/98. It 'locks' a disk so DOS programs can have direct access to it (Without windows acting on its behalf during disk access). It will warn you that corruption can occure if you use it. Heed that warning. If you have a DOS program that must be run with the disk being 'locked' it is probably pretty old and may not understand how to act with the windows 'enhancements' on the disk. If you just have to still use that program I would recommend only using it on machine running the version of DOS it was made for. Otherwise make a backup of your system before you mess with it. To unlock a disk see UNLOCK in the next section.













UNLOCK
This unlocks a drive from direct disk access. See above, LOCK for more.




















EXIT
This exits the current command shell. In windows it will close your DOS window. (Unless you have more than one instance of command.com running). If you are at a real DOS prompt (No windows in the background) nothing will happen.

If you start another instance of command.com (By typing 'COMMAND') then you will have two shells running. Anything you do here will not affect the previous shell. Example: if you change your path statement in a secondary shell, when you exit all your environment variables will be lost and go back to what they where in the first shell's environment.




















LOADHIGH aka LH
This tries to load a program into high memory. (For the purpose of freeing up more conventional memory.) LH is the same command as LOADHIGH. In order to use it you MUST have the following:
DOS=UMB in your config.sys file
Himem.sys and Emm386.exe installed

It should especially be used with things like your mouse driver that are in memory the whole time DOS is running.




















TRUENAME
This is an undocumented command in MSDOS since version 5. The reason it's not documented is that it doesn't work. The name would suggest it tells the fully qualified name of a file (C:\dos\format.com versus just format.com). When you type just TRUENAME it will show you your current directory and drive. If you add anything after truename it will erroneously show it as an actual file or folder on your current drive.




















WILDCARDS * and ?
coming soon...
This web page is copyrighted by Nathan Heald. Reproduction is allowed as long as this message is not removed or modified in any way. Frames site  No-frames site. How to print pages off of this site. The official URL of DOS HeadQuarters is http://dos.rsvs.net