• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
File Compare (comp)\windows\system32\comp.exe

Compare the contents of two files (or sets of files) byte-by-byte and display the differences between them.

To Open

Command Prompt comp


comp [file1] [file2] [/n=number] [/c] [/offline] [/d] [/a] [/l]


File Compare (comp.exe) compares two files (or more, using wildcards), and reports whether or not the files are identical. If the files are identical, comp.exe will report Files compare OK. If the files are the same size but have different contents, comp.exe displays the differences, character-by character, by reporting Compare Error at OFFSET n (where n is byte offset — the location of the difference, in characters, from the beginning of the file). If the files are different sizes, comp.exe reports Files are different sizes, and the comparison stops there.

Here are the options for comp.exe:

file1, file2

Specify the filenames of the files to compare. For any files that aren't in the current directory, you'll need to include the full path. If file1 includes a wildcard, all matching files are compared to file2. Likewise, if file2 includes a wildcard, each matching file is compared to file1. If one or both of these parameters are omitted, Comp.exe will prompt you for the files to be compared.

/n= number

Include the /n option to compare only the first specified number of lines in the files, or omit to compare the entire files. For example, specify /n=5 to check on the first five lines in each file.


Disregard the case of ASCII characters; upper and lower case letters are treated as identical.


Comp.exe normally skips files marked as "offline." Specify /offline (or just /off) to include offline files as well. (See Synchronization Manager, later in this chapter for more information on offline files.)


Displays differences in decimal format.


Displays differences in ASCII characters. The /a option is the default, so specifying it has no effect.


Include line numbers in any output.


  • Windows XP actually comes with two file comparison utilities, comp.exe (this one) and fc.exe (discussed in the next section). Comp.exe performs a character-by-character comparison, but only displays differences if the files are exactly the same size. Fc.exe performs a line-by-line comparison and works regardless of the file sizes. For most users, fc.exe will be the tool of choice, as it displays the differences between the files and doesn't have any prompts, so it can be used from a WSH script or batch file.

  • Regardless of the outcome of the comparison, comp.exe will ask if you want to perform another comparison. Although there's no way to disable this prompt, you can use the following workaround to bypass it:

    echo n | comp file1 file2

    See Chapter 6 for more information on the Echo commnad.

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint