Blog Archive

Monday, 2 July 2007

The Dark World of DOS

One of the fastest ways of doing things in Windows XP is to use DOS commands. Today's tip deals with the mysterious DOS command line interface and some of the many things that can be done with it.


  • Getting started
    • To open the command prompt: Start > Run…, type cmd and hit Enter.
    • If you need to type lengthy file or folder name, you can drag the file or folder from Windows Explorer directly into the DOS command line interface.
    • If you would like help for any command, type the command name followed by a space, then/?, e.g. dir /?.

  • Some useful commands

    assoc – Displays which programs will open the file with .xyz extension.
    It can be used either to display or modify file extension associations. If you just type assoc then it will display the list of all file extensions and associated programs used to open that file. For example, assoc .doc will show you the name of the program which the file is associated with.

    attrib – Displays and changes file attributes (i.e. make hidden files visible).
    It displays, sets, or removes the read-only, archive, system, and hidden attributes assigned to files or directories. For example, if you want to edit a desktop.ini file that's hidden you can use attrib commands to unhide it and edit it.
    • attrib tips: "+" – adds an attribute. "-" – removes an attribute
      Example: C:\Documents and Settings\[user id]>attrib resume.doc +r or C:\Documents and Settings\[user id]>attrib rk-resume.doc +a -h
      Key: a = Archive, r = Read-Only, h = Hidden, s = System

    cd – Displays a list of files and subdirectories in a directory and also can change directory or folder (i.e. Directory is called folder in windows world).
    It displays the name of the current directory or can change the current folder.
    • Display the name of the current drive and folder: cd
    • Change directory to another path: cd pathName

    cls – Clears the command prompt window.

    control – Launch Control Panel from command prompt.
    This allows you to launch control panel applets from the command line.

    dir – Displays a list of a directory's files and subdirectories.
    If it is used without parameters, dir displays the disk's volume label and serial number, followed by a list of directories and files on the disk, including their names and the date and time each was last modified. For files, dir displays the name extension and the size in bytes; dir also displays the total number of files and directories listed, their cumulative size, and the free space (in bytes) remaining on the disk. Some examples:
    • List the contents of the current directory: c:\>dir
    • Lists contents of a path: e.g. dir c:\program files
    • Wildcards: *
      Wildcard usage: c:/windows/system32>dir *.exe - will display files with .exe extension or c:/windows/system32>dir *.* - will display the file with any extensions.

    driverquery – Displays a list of all installed device drivers and their properties.

    systeminfo – Know your computer configuration.
    It displays detailed configuration information about your computer and its operating system. It includes operating system configuration, security information, product ID, and hardware properties, such as RAM, disk space, and network cards etc.

    tree – It displays the directory structure of a path or of a disk drive graphically.
    Windows XP doesn't have direct command to print directory content so you can do that by combining following commands together.

    Try this tree DOS command and redirect the output to a text file.
    • tree > directorycontent.txt
    • print directorycontent.txt
    The file will be stored under the location you are currently working in, like C:\Documents and Settings\UserID.

    type – View txt files in command prompt without opening it with Notepad It displays the contents of a text file. The type command is mostly used to view text files without modifying them.

No comments:

Post a Comment