Update the FC command with a new look and feel

When comparing two text-based log files, the old DOS command File Compare (FC) is handy to track down any changes that might have occurred. Greg Shultz updates the FC command to make it easier to evaluate report file results.

When you use utilities that create ASCII-based report files, such as the Driver Query Tool I presented in "Put the GUI on Windows XP Pro's Driver Query command-line tool," chances are good that you’ll want to compare two files to track down changes. For example, suppose you run the Driver Query Tool when your system is working properly and then save the report to a file. Then, if the system exhibits problems that could be the result of missing or corrupt drivers after installing a new device, you can run the tool again, save the second report, and then compare the two reports to help you quickly pinpoint anything that has changed.

While you could open the two files side by side and manually check for differences, that’s not really a practical approach. The better way to perform the compare operation would be to use the old DOS FC, or File Compare, command. This DOS-based command can be frustrating for several reasons. First, typing long path and file names on the command line can be a trying experience. Second, analyzing the results from the Command Prompt window can be difficult if the files are long. I’ve developed a neat little HTML Application (HTA) that uses Windows Script Host and VBScript to give this handy tool a GUI front end. I'll introduce you to the File Compare Tool HTA and explain how it works. Then, I'll show you how to use it.

Installing the File Compare Tool
Once you download the File Compare Tool installation package, double-click the FCT Setup.exe file. The installation program will prompt you to choose a folder in which to install the application. If the folder doesn’t exist, the installation program will create it for you. After you install the File Compare Tool, you’ll see these three files in your folder:
  • FileCompare.hta
  • FileCompare.ico
  • Support.cnt

To make the File Compare Tool easy to access, you can right-click on the FileCompare.hta file and select Send To | Desktop (Create Shortcut). You can then rename the shortcut and place it on the Start menu.

How the File Compare Tool works
The File Compare Tool will give you a dialog box in which you can select the two files you want to compare and select the options you want to put into effect during the file compare operation. Obviously, choosing options from a dialog box and passing them to the command line is a pretty straightforward operation. However, finding a way to allow the user to choose files turned out to be a bit tricky.

I had first planned to use the BrowseForFolder method exposed by Internet Explorer (IE), which is supposed to allow you to select files as well as folders, but I couldn’t get this method to work consistently across all the Windows operating systems and versions of IE. Unfortunately, neither VBScript nor Windows Script Host provides you with an easy way to browse for files from within a script. I then discovered an interesting technique presented by Joe Priestley.

In this technique, you create a class in VBScript that can in turn create a standard Browse dialog box and process any input retrieved by that dialog box. To create the Browse dialog box, the script in the class creates a temporary HTML file that includes a File Type input tag. The technique then launches an instance of IE, loads the HTML file, and presents a Browse button. Clicking the Browse button then opens a standard Browse dialog box from which you can choose a file. When you click OK, the filename and its path are passed back to the VBScript class block, where they can be used in the script. It’s not the most elegant technique, but it does work wonderfully in all versions of Windows and IE.

Now, as I mentioned, the File Compare Tool is implemented as an HTA, which allows you to put a professional-looking interface on a script. However, I’ve discovered that because HTAs are based in IE, they have limited support for certain features readily available to Windows Script Host and VBScript. And those missing features are needed to automate the FC command. So, the File Compare Tool HTA actually uses a roundabout method of presenting the standard Browse dialog box.

The HTA accesses the VBScript contained in the Support.cnt file and runs it. This script contains the class, which creates the HTML file, which ultimately creates the Browse dialog box. All of this occurs in the background—you just click a button in the HTA, see the Browse dialog box, and make your file selection.

Using the File Compare Tool
Now that you have a pretty good idea of the inner workings of the File Compare Tool, let’s take a look at how you use it. When you run FileCompare.hta, you’ll see the main window, as shown in Figure A.

Figure A
The File Compare Tool presents you with a nice GUI front end to the good old DOS-based FC command.

Next, when you click either one of the buttons in the Get Files panel, you’ll see a standard Browse dialog box titled Choose File, as shown in Figure B. You can then choose any file you want. As soon as you click on a file, the Browse dialog box will disappear and you’ll be back at the File Compare Tool window.

Figure B
When you see the Browse dialog box, you’ll also notice a small IE window appear in the upper left portion of the screen.

I’ve annotated Figure B with an arrow to point out a very small IE window. This is the HTML file that creates the Browse dialog box. Since I’ve created the script to automatically click the Browse button, there’s no need for the user to interact with this window. However, for this technique to work, this window must be in the foreground. I’ve purposely made the window as small as possible to keep it out of the way (I’m pointing it out so you’ll know what it is when you see it).

When you select a file from the Browse dialog box, this small window will close. If you don’t select a file right away or click Cancel, this small window will automatically close after approximately one minute. Once you’ve selected your two files, you can use the options in the File Compare Tool window to configure how you want the FC operation to work. If you need assistance understanding the options, you can click the Help button and see a short overview of each option.

When you click OK, the File Compare Tool will shell out to a DOS prompt and run the FC command. As it runs the command, the results of the FC operation are sent to a report file, which is saved in the same folder containing the File Compare Tool HTA. The report file is then instantly opened in Notepad, as shown in Figure C.

Figure C
The File Compare Tool will instantly display the results of the file compare operation in Notepad.

As you can see, the name of the report file contains the date and the exact time the report was created. This allows you to create multiple reports within a short timeframe without overwriting previous reports.

For more GUI-based utilities, check out these links
If you’re like me, you loathe the DOS command line. It’s clunky, cryptic, and prone to human error. However, as an IT pro, you cannot get around its usefulness for extracting information about a system. To help you get the functionality out of the command line, while preserving the GUI look and feel of Windows, I’ve created a series of downloads devoted to eliminating the need for the DOS command-line interface. Check out these downloads and let me know if there are any other DOS-based commands you would like to see with a GUI interface:
  • Driver Query tool HTA: This HTML Application (HTA) uses Windows Script Host and VBScript to give XP Pro's Driver Query tool a GUI front end.
  • The XCopy Tool HTML application: This download uses VBScript and the Windows Script Host to allow you to run the XCopy command from within the Windows user interface.
  • The PathPing utility script: Streamline the use of the PathPing utility by moving it out of the "command-line-only" category and giving it a GUI front end with Windows Script Host and VBScript.
  • Network Monitor Capture Utility script: This download streamlines the Network Monitor Capture Utility by giving it a wizard front end. This wizard front end not only makes it easier to use this awesome tool, it also harnesses all of the powerful configuration options.



Greg Shultz is a freelance Technical Writer. Previously, he has worked as Documentation Specialist in the software industry, a Technical Support Specialist in educational industry, and a Technical Journalist in the computer publishing industry.

Editor's Picks

Free Newsletters, In your Inbox