miércoles, 7 de mayo de 2008

How to navigate in the DOS command prompt

Earlier today I had to boot a clients computer into Safe Mode and delete a virus via the DOS command prompt because if Windows loaded, the file would become locked and hence undeleteable! There are several other reasons why you may have to use the command prompt in your life (though rarely), so it’s good to know how to navigate your way around!

If you’ve been wanting to learn how to use the command prompt in Windows, I’ll go through some of the basic MS DOS commands that are performed most often. Just so everyone’s on the same page, you can get to the command prompt by going to Start and then click on Run and typing in CMD.

command prompt

You’ll now see a large black window with the cursor at the end of the path to your user profile in C:\Documents and Settings\Username. So what to do now!? Well, since I can’t explain everything, you’ll probably want to end up using some of the help guides that are provided in MS DOS itself by typing in HELP and pressing Enter.

When you do that, you’ll get a list of all the commands you can use in MS DOS and a short description of what they do:

ms dos

You can also find out more detailed information about the parameters and how to use each command by typing in the command name followed by a /?. For example, typing in CD /?, will present you with a quick tutorial on how to use the CD command:

command promt commands

As you can see from above, the MS DOS command CD displays the name of or changes the current directory. So if you wanted to change from the default user profile directory to let’s say the Windows System32 directory to delete a virus file, you would type in the following to navigate to that directory:

cd c:\window\system32 and press Enter

You current directory at the prompt will now change to:

ms dos commands

Now that you are in that directory, you may want to view all of the files and directories first, so you can type in the command DIR and press Enter. You’ll now get a giant list of all of the files and folders in that directory. You can type in DIR /? and see what parameters you can pass to it.

dir ms dos command

As you can see, you could type in DIR /P to give the list in a paginated format that you can browse through slowly. Or you could type in DIR /W to get the list in a wide format rather than one single column. The cool thing about DOS is that you can include several parameters for each command, so you could type in DIR /P /W and get a page by page view along with wide format:

dir dos command

There are lots of other commands that you can use to do all sorts of stuff like copy files, make directories, print text files, delete files, etc. So if you can do most of this stuff in Windows using the GUI interface, then why bother with DOS, right?

Well, the cool thing is that any command you type in the command prompt, like we showed above, can be saved into a file with a .BAT extension and run anytime by just clicking on the file or can be scheduled to run using the Windows Scheduled Tasks Control Panel applet.

So if you want to be able to routinely perform some simple actions on your computer, like copying files from one folder to another, just type the commands into Notepad and save the file with a .BAT extension instead of as a text file. Basically, you have to choose All Files for the File Type option and then type in the name like “MyFile.bat” with the quotes included.

bat file

A couple of other very useful commands that you might have to end up using are listed below:

  • chkdsk - Verifies a hard disk or a floppy disk for file system integrity.
  • copy - Copies files from one location to another. The destination defaults to the current directory. If there are multiple source files, the destination must be a directory or else you will get an error.
  • fc - Compares two files or sets of files and displays the differences between them
  • fdisk - Manipulates hard disk partition tables. When run from the command line, it displays a menu of various partitioning operations.
  • format - Delete all the files on the disk and reformat it for MS-DOS. Use mostly for formatting floppy disks or other removable disks.
  • scandisk - Disk diagnostic utility that is a replacement for the CHKDSK utility.
  • SFC - System File Checker - Scans all protected system files and replaces incorrect versions with correct file versions.

That should hopefully get you up and running on how to use and navigate in the MS DOS command prompt! If you have a question, please post a comment! Enjoy!

No hay comentarios:

 
Locations of visitors to this page