Speed up Windows 98 applications with Winalign

While trying to improve the speed of Windows 98, Michael Freeman ran across two obscure utilities that come with Windows 98: Walign and Winalign. Read how you can use these features to optimize large executable files and speed up certain applications.

Like many users of the new Windows 98 operating system, I’ve been disappointed by the fact that Windows 98 doesn’t seem to run programs any faster than Windows 95 did. Since I’m a computer trainer who’s constantly searching for ways to optimize Windows, I began to investigate this frustrating aspect of Windows 98. Eventually, I stumbled across two little-known features that were introduced with Windows 98: Walign and Winalign. With a proper understanding of these features, you can speed the launching of programs that you run frequently. Both Walign and Winalign force applications to start faster and to use CPU time and memory more efficiently.

What do Walign and Winalign do?
I learned about these utilities when participants at my computer seminars expressed concern over the way in which Windows 98 freezes during the installation process. There was no apparent activity for up to five minutes before the system suddenly came back to life again. Intrigued, I turned to the Microsoft KnowledgeBase to search for information about this specific problem. Article #191391, which is entitled “Computer Appears to Stop During Windows 98 Setup,” mentioned that Walign.exe was probably the cause and referenced KnowledgeBase articles about Walign and Winalign, a companion utility. As I searched for information on Walign and Winalign, I came across KnowledgeBase article #191655, which presented an overview of both executables. This article discussed the Windows 98 CacheMap feature and the performance benefits that are associated with using 4-KB boundaries. Apparently, Microsoft had discovered that it was better to use memory in Windows 98 by aligning application code on 4-KB boundaries within the applications disk file. Still, I needed more information to justify using the new utilities.

Then, I turned to the definitive text on Windows 98: the Microsoft Windows 98 Resource Kit (from Microsoft Press). This book explained that the memory page size of the Intel x86 chip family is 4 KB; therefore, aligning the executable sections of programs on these 4-KB page boundaries would optimize their performance by optimizing data caching.

Windows 98 already uses MapCache, a performance feature that causes programs to consume less memory. However, the memory-mapped I/O that the new utilities create keeps only one copy in memory (instead of two). Thus, less usage of the swap file will occur. (The swap file uses the slower disk I/O.) There also will be increased memory for running programs. When code is aligned in this manner, Windows 98 will run the application directly from the memory cache in more efficient, 4-KB chunks. Windows 95, on the other hand, always copies code from the disk cache area into another memory area, which causes extra memory usage. Some benchmarks show that aligned executable files load 10 percent or 20 percent more quickly if you repeatedly open and close them throughout the day.

Where do we go from here?
Virtually all of the utilities and applets that come with Windows 98 are aligned already. Microsoft supports aligning its own applications, and third-party vendors align their own software before they ship the software. Microsoft includes the Walign utility within Windows 98; however, it’s only designed to align Microsoft Office components. The full version of the utility (called Winalign) is located on the CD-ROM that comes with the Microsoft Windows 98 Resource Kit manual.

After you successfully complete an installation or upgrade, boot Windows 98. If Walign finds Microsoft Office version 7.0 for Windows 95 or Microsoft Office 97 on your hard drive, Walign will attempt to align one of these versions of Microsoft Office and some DLLs. A small dialog box will appear during the process and inform you that setup is modifying your programs so that they will start faster. Afterwards, a report of the success or failure of the process (with a name similar to Winalign_report.txt) will be created in the Windows\system directory. A version of this report is shown in Figure A.

Figure A
Walign reports the success or failure of the alignment process.

If this initial alignment fails—and it sometimes will—you must run the utility again. Check the alignment status of programs before you attempt to run either Walign or Winalign on your own. To check the alignment status of a particular program, use Windows Explorer to locate the EXE or DLL file. For example, if you want to check on the alignment status of Microsoft Word, the executable filename is WinWord. Right-click on WinWord in Windows Explorer and select Quick View from the menu. If Quick View isn’t available, you need to install it before continuing.

Installing Quick View
To install Quick View, make sure that your Windows 98 installation or upgrade CD is available. Insert the Windows 98 CD in the CD-ROM drive. In the Control Panel, double-click on Add/Remove Programs and select the Windows Setup tab. In the Components dialog box, highlight Accessories and select Details in the Description dialog box. In the components dialog box, scroll down until Quick View appears. Click inside of the selection box (just to the left of Quick View) and click OK at the bottom of the screen. You’ll return to the Add/Remove Program Properties tab. Click OK to initiate the installation of Quick View. Follow the system prompts to complete the installation.

Checking alignment with Quick View
In the Quick View screen, scroll down to the section called Image Optional Header. Look for two sections called Section Alignment and File Alignment. If the program has been aligned already, both sections will display a value of 00001000 in the right-hand pane. An unaligned file probably will have a value of 00000200 for the File Alignment section. Figure B shows an aligned program, and Figure C shows an unaligned program.

Figure B
An aligned file in Quick View shows a value of 00001000.

Figure C
An unaligned file in Quick View shows a value of 00000200.

Don’t try to align every executable program on your system. Some programs will fail to run properly or will perform erratically. The Microsoft Windows 98 Resource Kit recommends not aligning the following file types with Winalign: NT system binaries (files), antivirus programs, programs that use checksums on themselves, patched system files, and other critical files. Instead, align large, slow-loading executable programs that seem to take a long time to start or programs that are continually launched and closed throughout the day. Think of large programs (such as Internet browsers, large databases, and graphic-intensive programs) as prime candidates for this procedure.

Installing and running Winalign
Installing the full version of Winalign is well documented in the Tools Help section on the Windows 98 Resource Kit CD. The installation process will place the new Winalign program in the Powertoy subdirectory. To run Winalign, you’ll have to place it in the directory that contains the files you wish to align. To run Winalign from the command prompt, move Winalign to the \Windows\Command directory. There are a number of syntax options and switches that you can use with Winalign. The general syntax for Winalign would be:
winalign [target] [-x | -i | -r] [-s] [-t] [n] [g]

In the above code, target specifies the directory or files to be processed. (By default, it’s All.) One of the two most common switches is –x, which causes Winalign to work off of an exclude list. This list must exist in the same location as Winalign, and it must be named Winalx.txt. It should contain a list of binary files to be skipped (one file per line). Relative paths—not absolute paths—may be used in this list. The other common switch is –i, which causes Winalign to work off of the default include list. This list must exist in the same location as Winalign, and it must be named Winali.txt. It should contain a list of binary files to be aligned (one file per line). Again, only relative paths may be used. Use the –t switch if you want the output to be directed to Winalign_report.txt, which is located in the directory that contains Winalign.exe. The -r switch restores previously aligned files.

Some examples
The following command aligns all of the binary files in the xyz directory and stores the results in Winalign_report.txt in the same directory:
Winalign c:\xyz –t

To restore the above files to their original, unaligned condition, type:
Winalign c:\xyz –r

As a precaution, you should make a backup copy of the program that you wish to align. Store it on another area on your hard drive. Do the same thing before you make any software changes.

If the aligned program fails to perform properly (or not at all), the -r option of the Winalign utility will restore files. Of course, the utility won’t back up the original program and files. Instead, the original alignment information is stored in a special key in the Windows 98 registry:

Look for the specific program name to see the key values. The restore feature remodifies the aligned file by trying to restore the original alignment values from the registry data. Not all programs will be restored successfully through this procedure; some will need to be completely reinstalled. This procedure will be less painful if the precautionary backup has been performed already.

Using Disk Defragmenter
Naturally, based on the information that was outlined in the Microsoft documentation, I expected significant improvement in performance. Imagine my disappointment when I didn’t see any immediate or noticeable effects. Again, I turned to the resource kit manual and reviewed the chapter on hard disk optimization. I came across an interesting discussion of the Windows 98 Disk Defragmenter utility. I soon realized that the culprit was Disk Defragmenter.

With the evolution of Windows from 3.x to 95, Microsoft improved the launching of applications by placing all of the files for the most frequently run programs in contiguous segments (clusters) of disk space. For Windows 98, a new approach to hard disk optimization was implemented. Following a different algorithm, Disk Defragmenter stores the components of the most frequently used program in the order in which they are loaded, including any needed system files. Often, Disk Defragmenter will fragment a file in order to improve its loading and starting speeds. These new algorithms reduce head rotation and seek time for the original loading and launching of frequently used applications. If you’ve been running Disk Defragmenter regularly, the programs are in their ideal locations. But what if you haven’t been using Disk Defragmenter?

Unfortunately, when you run Winalign, Windows stores the newly aligned program in a different location on the hard disk. Consequently, it takes time for the Disk Defragmenter to reorder the hard disk and the newly aligned files. Disk Defragmenter uses the results of the Task Monitor program, which monitors application usage and the number of times that applications run.

To view the optimization order that Disk Defragmenter uses, look for the Optlog.txt file in the \Windows\Applog folder on your hard disk. You can view this log through Notepad. You’ll see a number of lgn files in the Applog folder (where n indicates the drive on which the program resides). These are the log files that Task Monitor keeps and that Disk Defragmenter uses during the optimization process. For more information on Optlog.txt, see KnowledgeBase article #186020. For a discussion on the usage of the Optlog.txt file and the modification of its parameters, refer to the Microsoft Windows 98 Resource Kit. Optlog.txt is a hidden file; to view it, you may have to set the View\Folder Options of Windows Explorer to Show All Files.

You may need to run Disk Defragmenter a couple of times before the full benefits of Winalign become apparent. I utilize PowerPoint regularly during my seminars and presentations; when I performed an informal, unscientific test with a good, old-fashioned stopwatch, I noticed an improvement of approximately 15 percent after optimization. Other legacy (older) applications showed a smaller improvement. Although Microsoft warns that third-party applications may not perform properly or may fail to run when you use Winalign, I haven’t experienced any major problems with any of my programs. Still, to be cautious, I always create a backup copy of everything before I run the utility.

If you’ve been discouraged by a lack of performance improvement when you switched to Windows 98, you ought to look into using Winalign to tune up your applications. This utility will provide you with another tool in your arsenal of Windows optimization techniques. To take full advantage of Winalign, you also ought to invest in the Microsoft Windows 98 Resource Kit. It will inform you of all the pros and cons of utilizing Winalign, and it will allow you to use the full version of this alignment utility in order to optimize your other applications. On a final note, let me remind you to back up everything before you do anything to your system. Although it’s an old cliché, an ounce of prevention is still better than a pound of cure.

Michael Freeman is a consultant and trainer who specializes in helping companies and government agencies improve their technical skills and performance. Each year, he delivers over 100 seminars and workshops across North America and the United Kingdom. Over the past 20 years, he has worked with a number of national and international firms, and he has taught college-level computer courses. He’s the principal in M & A Consulting, and he’s a member of the Association of Independent Consultants and of the Society for Training and Development. Michael is also involved in several local heritage preservation groups, and he has received national recognition for his charitable activities. Michael is married and has two children.

The authors and editors have taken care in preparation of the content contained herein, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for any damages. Always have a verified backup before making any changes.

Editor's Picks

Free Newsletters, In your Inbox