You're the administrator of a large Windows NT Server farm. One of your most labor-intensive tasks is keeping your large collection of Emergency Repair Disks (ERDs) up-to-date. Several times you've needed a more current ERD than you had available, and thus the recovery took longer than necessary.
Recently, you installed the Task Scheduler that comes with Microsoft Internet Explorer (IE) 4.0 on all your servers and scheduled rdisk.exe to run regularly. You're concerned that the scheduled ERD information update isn't occurring on all the servers. Thus, you want to develop an NT shell script that determines the age of the ERD information on each server and displays this information in an HTML report.
Shortly after you write your ERD script, you receive a request from the administrator in charge of backups. Someone had remotely installed new backup software on the clients, and now the backups are failing. In his request, he asks you to create a script that
- Determines the date of the file backup.exe on each client workstation
- Compares the date of the workstation's file with the date that the clients received the new backup software
- Visually displays any discrepancies between the dates
- Displays this information in an HTML report
You realize that with minor modifications, you can use your ERD script to fulfill the administrator's request. Leveraging the code you've written for the ERD task, you use the Set command to assign the target filename and default and nondefault target directories. More important, you use the Set command to assign a comparison date (i.e., the date you want to compare the file dates against) as an environment variable. When the script runs, the system compares the file dates against the comparison date you specify. If the dates don't match, the system displays the offending files in red type in the HTML report. If a server is unreachable or the specified directory isn't in the default location, the script displays N/A for that particular file.
The finished script, FileDateReport.bat, obtains the date of any file or directory on the servers you specify in the input file servers.txt. Figure 1 shows an example input file. If you set a comparison date, the script also tests those dates against the comparison date you specify.
Listing 1 contains an excerpt from FileDateReport.bat. You can find the entire script on the Win32 Scripting Journal Web site (http://www.winntmag.com/newsletter/scripting). I configured this script to gather only the dates of ERD data in the repair directory. Screen 1, page 10, shows an example ERD report that you receive from running this configuration of FileDateReport.bat. The script includes comments to help you reconfigure the script if you want to compare dates. Here are the steps to get FileDateReport.bat working:
- Enter the location of the input file servers.txt.
- Enter the comparison date if you want the script to make date comparisons. Use the date format mm/dd/yy. For example, if you want the comparison date to be September 17, 1999, you specify
Set Compare_File_Date=09/17/99If you don't want to make date comparisons, make sure the line reads
- Enter the filename of the HTML report.
- Enter the friendly name you want to appear on the HTML report.
- Enter the filename of the test target.
- Enter the default directory path to the test target.
- Configure any paths for folders that don't use the default directory path. Place each exception on a separate line.
- Configure the path to the intranet Web server on which you're posting the completed online report.
- Change the Findstr command if you're running the script on a Windows 2000 (Win2K) system. I wrote FileDateReport.bat for NT 4.0 Service Pack 5 (SP5). The Findstr command handles classes of characters differently on a Win2K system than on an NT system. For the script to work properly on a Win2K system, you need to change the Findstr command for the filename
Findstr /i /e /C:"\[0-9\] %File_Name%"to
Findstr /i /e /C:" %File_Name%"
- Test the script to make sure you've configured it correctly.