Operating Systems
What is Disk Operating System?
More commonly known as Microsoft DOS (Disk Operating System) is a command line user interface. MS-DOS 1.0 was released in 1981 for IBM computers and the latest version of MS-DOS is MS-DOS 6.22 released in 1994. While MS-DOS is not commonly used by itself today, it still can be accessed from Windows 95, Windows 98 or Windows ME by clicking Start / Run and typing command or CMD in Windows NT, 2000 or XP.
Tips
Don't Forget - Check Your Memory!
To check the available memory left on your machine, use the MEM command. Thereare several options available (depending on the version of Dos/Windows you areusing) so type
MEM/?
at the DOS prompt to see what kind of memory checks you can perform.
Forcing the Directory to Display a Certain Way
If you wish to set the directory listings a certain way (when you use the DIRcommand), set the DIRCMD environmental variable to the parameters you wish touse.
To see a list of possible parameters for the DIRCMD, see the list of possibleparameters for the DIR command. Type
DIR /?
To set the DIRCMD environmental variable, add the line
SET DIRCMD=xxxx
in your AUTOEXEC.BAT file, replacing 'xxx' with the parameters you wish touse. For example, the parameter "/ON" would cause your DIR results tobe automatically sorted by filename. The "/W" command automaticallysets the DIR results to a wide-directory format.
Use Your Up Arrow For Latest Dos Commands
The DOSKEY program is very useful for many reasons, but some people feel thatthey do not need its powerful features and fail to install it. If for no otherreason you should install DOSKEY, do so for this trick - with DOSKEY installed,using the up-arrow scrolls through your latest DOS commands. If you use DOS alot, this is a *lifesaver!*
Install DOSKEY by editing your AUTOEXEC.BAT file with EDIT or any other texteditor. Add the line "DOSKEY" or "LH DOSKEY" to the end ofyour AUTOEXEC.BAT file. If this fails to work, you need to add a line to the endof your AUTOEXEC.BAT file with the full path to the DOSKEY.COM program. If youare using Windows 95, DOSKEY.COM probably is in your C:\WINDOWS\COMMANDdirectory. If you are using DOS 6.xx or earlier, it is probably in your C:\DOSdirectory.
For example, if DOSKEY.COM is found in your C:\DOS directory, add a line tothe end of your AUTOEXEC.BAT file as follows:
C:\DOS\DOSKEY
DOSKEY takes up just a little bit of memory so if every byte counts, you'llhave to live without its usefulness.
Secret (?) Directories
Although this doesn't keep advanced users away from your files, when namingprivate directories, use this instead of a space: Hold down the ALT key whiletyping 255 from your numeric keypad. While this looks like a space, it isn't.
Backup your Configuration Files
Before you make any major changes or software installations, ALWAYS back up yourAUTOEXEC.BAT and CONFIG.SYS files. Many software programs will make updates tothese files without your permission, potentially causing many problems anderrors on your system.
Extended Pattern Matching
You may know that with just about every version of DOS, using the '*" in acommand matches all files which match the characters before the asterisk. Inlater versions of DOS, however, you can use the asterisk to select every filewhich matches the character after the asterisk.
For example, a DIR *EC.* in the root directory could match filesAUTOEXEC.BAT, AUTOEXEC.DOS, DUALEXEC.INF, and LEC.TXT. And yes, you can do apattern-match with characters before and after the asterisk.
Redirect the Positions of the Redirect
When you perform a command involving redirecting the output such as DIR *.TXT> TEXTLIST, you normally place the redirection symbol after the command youare redirecting. You don't have to do this. The command > TEXTLIST DIR *.TXTworks fine.
Need Quick Help on a Command
Do you need help on a DOS command (or a DOS command in Win3.1/95?) Depending onthe version of DOS you are using, either type in HELP and the command-name ortype in the command-name and /? to receive help on the command.
Another Way to Show Fragmentation
Instead of using DEFRAG, you can check individual files or groups of files tosee if they are fragmented. To do so, type in 'CHKDSK filenames', where'filenames' is a filename or group of filenames you would like to check.
For example, to check the GAMES directory for fragmentation in *.DAT files,type in this command.
CHKDSK C:\GAMES\*.DAT
CHKDSK will give you a report of each file's non-contiguous blocks. The morenon-contiguous blocks a file has, the more fragmented it is.
List Every File on Your Hard Drive
To list every file on your hard drive, you could pull out some combinations withDIR /S to show files in all subfolders, or you can just type in CHKDSK /V. Doingso will show every file on your hard disk, and at the end, will show you areport of the total disk space, total free space, and more.
Save this report to a text file for later viewing. Type in
CHKDSK /V > DISKREPORT.TXT
Too Much Help
Have you ever performed a /? on a DOS command to view help, only to find thehelp scrolling off the screen? Don't panic. Just add '> txt' to the end ofthe command, and you'll find a textfile called 'txt' that has the contents ofthe help.
For example, to view the help on the DIR command, which under some versionsof DOS will contain enough information to fill up and scroll one screen, type inthis command at the prompt - "DIR /? > tmp" (without quotes).
Sort Order Shortcut
The help for the DIR command may be confusing regarding performing sorts. You donot have to use a colon in conjunction with the /O command to perform a sort.
For example, to sort files by size, DIR /OS works just as fine as DIR /O:S
Another way to REMark
Instead of using just the REM command to place remarks in batch files, you cando the following to make the batch file easier to read.
Use a semicolon as the first character of the remark line, then tab twice,type in REM, a space, and then your remark. Placing your comments in the middleof the line may make the file easier to read.
More Version Information
In later versions of DOS, you can use the VER /R command to show more versioninformation, including the DOS revision and where DOS is loaded.
Copy Command Shortcuts
To copy files, one would normally type in the following.
COPY sourcefilepath\sourcefile(s) destinationfilepath\destionationfile(s)
If you are currently in the source file path's directory, you probably knowthat you can skip that part of the COPY command. What you may not know is thatyou can do the same if you are in the destination file's path.
For example, say you are in the C:\BITMAP directory, and you want to copy allof the BMP files from the A: drive to C:\BITMAP. Instead of typing
COPY A:\*.BMP C:\BITMAP
You can just type
COPY A:\*.BMP
Display a Blank Line in a Batch File
Typing ECHO and just a space in a batch file does not display a blank line -just 'Echo is on' or 'Echo is off.' To display a blank line, type in ECHO and aperiod using no spaces in between- ECHO.
Implementing the WAIT Command in a Batch
Do you need a batch file that waits a certain amount of seconds? In somelanguages, the command would be WAIT, but batch files do not come with thiscommand. If you want to implement this command, create the following batch fileand name it WAIT.BAT.
@CHOICE /T:N,%1% > NUL
Now, in order to wait 10 seconds in a batch file, just call the WAIT.BATbatch file as follows:
CALL WAIT 10
Always Fail on Abort, Retry, Fail
If you always want a prompt such as "Abort, Retry, or Fail?" or"Abort, Retry, Ignore, or Fail?" to fail, use the /F command-lineoption when running COMMAND.COM.
Pausing Directory Listings
If you don't know how to pause a directory listing, add '/p' (without quotes)to the end of the DIR command. So, if you want to display the directory but youwant the output to pause after displaying a screen of text, the command is DIR/P
Turning off Batch File Output
There are two ways to turn off the output from batch files. Entering the line@ECHO OFF at the beginning of a batch file should turn off the display ofcommands. Some DOS commands will ignore this statement, however, and continue todisplay text. If so, redirect the batch file's output to a text file or 'NUL.'For example, to hide the contents of batch file RUN1ST.BAT, use this to executethe batch file.
RUN1ST.BAT > NUL
You need to experiment with this. Some commands or programs may reactadversely to this output redirection, and some programs may ignore theredirection.
Create 0 Byte Place Holder Files
If you need to create files from a batch file that merely act as place holders(i.e. they take up no hard drive space, just space in the directory), use theREM command and redirect its output to a filename of your choosing. This can beuseful in case you have a batch file that works in many directories. You canhave the batch file put a placeholder in every directory it acts upon, allowingyou to see if the batch file worked correctly or not.
Need Quick Help on a Command
Do you need help on a DOS command (or a DOS command in Win3.1/95?) Depending onthe version of DOS you are using, either type in HELP and the command-name ortype in the command-name and /? to receive help on the command.
Emergency Scenario - Write Batch Files without Edit
OK, here's the scenario. You have a boot disk and you had to use it in order toset up a system. Now, you need to make a batch file for some reason (perhaps atemporary AUTOEXEC.BAT). But, you forgot to copy the EDIT program that would letyou type up a batch file. What do you do?
At the DOS prompt, type:
COPY CON NAMEOF.BAT
Type your batch file, line by line, pressing CONTROL-Z and then enter at theend of the last line.
Type very carefully. You will not be able to modify what you typed inprevious lines.
Double your Lines
Type the following in a DOS prompt to double the amount of lines:
MODE CON COLS=80 LINES=50
If you are strictly running DOS, you must have ANSI.SYS installed. If you arerunning DOS underneath Windows, this should work.
Quickly Get COM and LPT Port Status
To get the retry and redirection status of your COM and LPT ports, enter thefollowing command:
MODE | MORE
Dos for Unix People
I use DOS a lot. I use Unix a lot. And, like others who use both OS's, Isometimes forgetfully type in the wrong command. I type in 'quit' when I mean'exit,' 'ls' when I mean 'dir', and so forth.
Why not create a few basic batch files in your root, batch, or commanddirectory that can help you out? Even simple one-line batch files like thefollowing may help when you want the computer to do what you want it to do, notwhat you tell it to do
echo @exit > c:\logout.bat
echo @exit > c:\quit.bat
echo @dir %1 %2 %3 %4 %5 %6 %7 %8 %9 > c:\ls.bat
Do you have other ways to make DOS easier for Unix people? How about theother way around? E-mail me at webmaster@envprogramming.com with your tip.
Rewrite the Master Boot Record
Ever need to rewrite the master boot record of your hard drive, due to areformat, virus, or partial hard drive failure? This command will do so:
FDISK /mbr
Find All Files Of A Given Type
Ever need to find all of your batch files on your hard drive? Or, need to findall of your text files? This quick batch file will let you type in the followingcommand:
FINDALL BAT
And it will display all of your batch files. Type:
FINDALL TXT
And it will display all of your text files.
Just create a batch file called FINDALL.BAT, consisting of just this line:
@dir /b /s *.%1 | more
Want to sort the results? Make FINDALL.BAT consist of this line:
@dir /b /s *.%1 | sort | more
View Files Without Extensions
You know that typing DIR *. and an extension name displays all filenames withsaid extension, so that typing DIR *.BAT displays all batch files, DIR *.SCRdisplays all screensavers, etc. What about when you want to display all fileswithout extensions? The following command does the trick:
DIR /A-D *.
Note that the /a-d modifier is needed, otherwise your list of files withoutextensions will also contain a list of subdirectories.
Rename All Files From One Extension to Another
(Note that this may not work on early versions of DOS, so experiment.)
If you ever need to rename all files in a directory from one extension toanother, for example, *.new to *.old, you can use wildcards with the renamecommand. In this example, the command would be:
rename *.new *.old
Removing Read-Only Property From All Files in Directory
I was recently asked how to remove the read-only property from all of the filesin a given directory. It seems that this person was copying a large number oftext and document files from a CD and all of the resultant files had the"R" property set. Luckily, changing this property for all files isquite easy.
To remove the read-only attributes of all files in a particular directory aswell as its subdirectories, the following command can be entered at the DOSprompt or in a batch file:
attrib -r DIRECTORY\*.* /s
Replace DIRECTORY with your desired directory. For example, if you arecopying files from a CD to the directory c:\cdfiles, after copying the files,the command to remove the read-only attributes would be:
attrib -r c:\cdfiles\*.* /s
Display ErrorLevel on the screen
Debugging batch files and need to see the error level results of every DOScommand echoed to the screen? Try this command:
COMMAND /Z
This echoes the command processor with 'errorlevel' echoed to the screen.
Display Your Command History
Need to know the last few or so commands that you entered at the DOS prompt? Youcan do so by first installing DosKey. Then, just press your F7 key at thecommand prompt. You'll see the last few commands entered in the current session.Better yet, you can re-execute previously typed commands (save yourself thosekeystrokes!) Press F9, type in the number corresponding to the command that youwant to re-execute, and presto, that command is at your DOS prompt!
If you need to clear your command history, press ALT-F7.
Place Date and Time in the Prompt
Always looking around for the current date and time? Why not place it in auseful place, say, the command prompt?
Add this line to AUTOEXEC.BAT:
prompt Time: $t$_Date: $d$_$p$g
Make a Floppy Bootable
A boot disk is a floppy disk that contains, at the very least, an operatingsystem. Boot disks are useful in case of a hard drive failure. With a boot disk,you can place a floppy disk in your computer when it boots up and still haveaccess to your computer.
While I highly recommend putting more than just the basic operating system ona boot disk, such as useful batch files, useful commands, device drivers, etc.,the following line *will* make a floppy disk bootable:
SYS C: A:
Dos for Unix People
Unix users - still mistyping commands at your DOS prompt? Here are a few moresmall batch files you can enter to alleviate your pains. Just type in thesecommands at the dos prompt, substituting C:\ with your batch file directory ofchoice.
echo @%1 /? > c:\man.bat
echo @copy %1 %2 %3 %4 %5 %6 %7 %8 %9 > c:\cp.bat
echo @move %1 %2 %3 %4 %5 %6 %7 %8 %9 > c:\mv.bat
|
|||