|
CMD File Modifications
Download Hotfix Reporter, or
join the mailing list.
Hotfix Reporter consists of two main files: Tab2Html.EXE, which converts the HfNetChk tabbed output into HTML; and HfReport.CMD, which runs HfNetChk and then runs Tab2Html.
The standard version of HfReport.CMD works fine for most users. However, there are several circumstances in which you may want to modify HfReport.CMD or combine it with other batch files to achieve different results. This page details several such alternatives.
Change history
11-2-01 Original version posted.
11-26-01 Updated HfReport-NetBIOS.CMD to put quotes around the %HOST% parameter on the CALL line. This is necessary when scanning multiple machines. Also, updated the section on Scheduling Automatic Scans to recommend using Task Scheduler instead of the AT command.
Scanning other machines
When you run Hotfix Reporter in the default configuration, HfReport.CMD will run HfNetChk which will scan the local machine for missing hotfixes. HfNetChk supports scanning other machines on your network; there are several ways to perform such scans.
You can control which machines are scanned by passing different parameters to HfNetChk. See the official HfNetChk documentation from Microsoft for details on the supported HfNetChk parameters.
- You can run HfReport.CMD manually from a command window, passing the appropriate parameters on the command line. This approach is useful for experimenting with the various HfNetChk parameters.
Example: If you want to scan your entire network, execute this statement on the command line:
HfReport -n
- You can edit HfReport.CMD so that it sets the appropriate parameters when running HfNetChk. The benefit to this approach is that the same parameters will be used every time you run Hotfix Reporter. The disadvantage is that you may lose any HfReport.CMD customization the next time you install a new version of Hotfix Reporter.
If you edit the call to HfNetChk in HfReport.CMD, be sure to keep the "-o tab" parameter and the "> cur-orig.txt" portion.
Example: If you want to scan your entire network, you may change the line in HfReport.CMD from:
HfNetChk -o tab %1 %2 %3 %4 %5 %6 %7 %8 %9 > cur-orig.txt
to:
HfNetChk -n -o tab %1 %2 %3 %4 %5 %6 %7 %8 %9 > cur-orig.txt
- You can create new program menu items (usually placed in your Administrative Tools menu) with calls to HfReport.CMD with the appropriate parameters. The HfReport.CMD file will pass any provided parameters to the HfNetChk command.
The easiest way to create a new menu item is to open the Administrative Tools menu folder, then copy and modify the existing "Hotfix Reporter" menu item. To open the Administrative Tools menu folder (on Windows 2000 or XP), click the Start button, then click Programs, then right-click on Administrative Tools and choose Explore All Users. (You may need to use a different method for your particular installation.)
After you've opened the appropriate menu items folder, make a copy of the existing "Hotfix Reporter" item and rename the copy to something like "Hotfix Reporter (scan entire network)". Then right-click on the item and choose Properties. On the Shortcut tab, edit the value in the Target field to append the appropriate parameters. Remember to keep the path to HfReport.CMD in quotes if it contains a space. Do not place the new parameters within the same quotes as the HfReport.CMD command; place them after the quotes.
You can create as many of these menu items as desired for each desired combination of machines to scan.
The benefit of this approach is that you can have as many of these menu items as desired, and they won't be overwritten when you install future versions of Hotfix Reporter.
- Copy the following lines into a new text file:
@ECHO OFF
REM Run Hotfix Reporter, prompting for machines (NetBIOS names) to scan
REM Ver 1.1, 11-26-01 KJS; put quotes around %HOSTS% param on CALL line
REM Ver 1.0, 11-2-01 KJS
REM Based upon a suggestion by user Mark Davis -- thanks, Mark!
REM Init
SET HOSTS=
REM Display welcome and instructions
ECHO Hotfix Reporter -- scan NetBIOS names
ECHO.
ECHO Enter NetBIOS names to scan (comma separated, no spaces).
ECHO Enter * to scan entire network.
ECHO Leave blank to scan local machine only.
ECHO Press Ctrl-C to cancel.
ECHO.
REM Prompt for host names
SET /P HOSTS="NetBIOS names> "
REM Determine what type of input we got
IF "%HOSTS%" == "" GOTO Call_Normal
IF "%HOSTS%" == "*" GOTO Call_N
REM Some value must have been provided (but not a *)
REM so call HfReport with the -h parameter
CALL HfReport -h "%HOSTS%" %1 %2 %3 %4 %5 %6 %7 %8 %9
GOTO Done
:Call_Normal
CALL HfReport %1 %2 %3 %4 %5 %6 %7 %8 %9
GOTO Done
:Call_N
CALL HfReport -n %1 %2 %3 %4 %5 %6 %7 %8 %9
GOTO Done
:Done
REM End.
|
Save the file with the name HfReport-NetBIOS.CMD (not HfReport-NetBIOS.CMD.TXT) in the same directory as HfReport.CMD and HfNetChk.EXE. Then add to your Administrative Tools menu a shortcut which points to this CMD file.
Using advanced HfNetChk options
When you run the main Hotfix Reporter batch file (HfReport.CMD), it will pass any parameters to the HfNetChk command. (Only up to 9 parameters are supported.) The following is a batch file which will prompt you for all of the available HfNetChk options; it is useful for trying out different options.
Download the file linked below by right-clicking on it and choosing Save Target As. Be sure to save the file with the name HfReport-AllOptions.CMD (not HfReport-AllOptions.CMD.TXT), and save it into the same directory as HfReport.CMD and HfNetChk.EXE. Then add to your Administrative Tools menu a shortcut which points to this CMD file.
HfReport-AllOptions.CMD
The only common parameter not supported by this file is the -x option, used to tell HfNetChk to grab the XML file from a different location. If you wish to use the -x option, either edit HfReport.CMD, or call HfReport-AllOptions.CMD with the appropriate parameters (-x location).
Emailing the scan results
You can easily modify the following batch file to email you the results of a scan. All that is needed is a program which can send email from the command line so you can call it from the batch file. A popular choice is blat. (Change the call to the blat in the file below if you use a different command line program.)
Hotfix Reporter stores its results in a file called results.htm, so be sure to configure your mailer program to send that file to the desired user. You should experiment with sending the file as the contents of an HTML message, or as an attachment to a simple text message.
Save the lines below to a file named HfReport-Emailer.CMD (not HfReport-Emailer.CMD.TXT), in the same directory as HfReport.CMD and HfNetChk.EXE. Then edit the appropriate lines to call your mail program with the desired parameters if you aren't using blat.
@ECHO OFF
REM Run Hotfix Reporter, then email results to admin
REM Ver 1.0, 11-2-01 KJS
REM Run Hotfix Reporter
CALL HfReport %1 %2 %3 %4 %5 %6 %7 %8 %9
REM Email the results
REM Choose one of the two methods below; delete or REM out the undesired method
REM Method 1: email as the contents of an HTML message
blat results.htm -html -to admin@yourdomain.com -subject "Hotfix Reporter"
REM Method 2: email as an attachment
REM But first echo the current date to a text file (blat must send a text file as the body)
date /t > date.txt
blat date.txt -to admin@yourdomain.com -subject "Hotfix Reporter" -attach results.htm
:Done
REM End.
|
Scheduling automatic scans
Hotfix Reporter does not include any built-in scheduling capabilities, but you can easily use the Windows Task Scheduler to accomplish the same effect.
If using Windows NT 4, open My Computer; if using Windows 2000 or XP, open Control Panel. Next, choose Scheduled Tasks. Double-click on Add Scheduled Task and follow the wizard's prompts. On the second wizard page you will need to click the Browse... button and then manually locate the appropriate batch file. On a following page be sure to enter the username and password of a user with appropriate permissions (usually, the Administrator user). You can edit the properties of the task if you need to specify additional command line parameters for the job. Be sure to enclose parameters in quotes if they contain a space or comma.
You should use the Task Scheduler instead of the AT command. Task Scheduler lets you define the user account that Hotfix Reporter should run as. The AT command usually runs tasks as the System user, which lacks sufficient permissions.
Downloading the mssecure.xml file automatically
If you want to automatically download the current mssecure.xml file from Microsoft, you need to use a third-party tool. One such tool is getHTTP (install it into a directory on your path, such as C:\WinNT, or into the same directory as HfNetChk and HfReport.CMD). The URL for the current mssecure.xml file is contained in the HfNetChk FAQ; the value is currently http://download.microsoft.com/download/xml/security/1.0/nt5/en-us/mssecure.cab. Note that the file is distributed in a CAB file; you need to use the expand tool to extract the mssecure.xml file from within the CAB file.
Please note that apparently Microsoft serves the actual CAB file from a different location than is specified in the above URL. The batch file given below shows the current value for actual CAB file.
Here is a simple batch file that downloads the current XML file then runs Hotfix Reporter. Save the following text into a file named HfReport-Download.CMD (not HfReport-Download.CMD.TXT). (Or you can download it). Then add an item to your Administrative Tools menu which points to HfReport-Download.CMD.
@ECHO OFF
REM Run Hotfix Reporter, first downloading current XML file
REM Ver 1.0, 11-7-01 KJS
REM Init
SET HR_URL=http://mssjus.www.conxion.com/download/xml/security/1.0/nt5/en-us/mssecure.cab
REM Download the file
gethttp %HR_URL% > mssecure.cab
REM Check errorlevel
IF ERRORLEVEL 303 GOTO Err_Unknown
IF ERRORLEVEL 302 GOTO Err_Redirect
IF ERRORLEVEL 201 GOTO Err_Unknown
IF ERRORLEVEL 200 GOTO OK
GOTO Err_Unknown
:OK
REM Got the file OK, now expand it
expand mssecure.cab mssecure.xml
REM Finally, call Hotfix Reporter, telling it to use the local file
CALL HfReport.CMD -x mssecure.xml %1 %2 %3 %4 %5 %6 %7
GOTO Done
:Err_Unknown
ECHO An unknown error occurred
ECHO The HTTP header returned was:
gethttp %HR_URL% -h
GOTO Done
:Err_Redirect
ECHO The location of the CAB file has changed
ECHO The new location as returned in the HTTP header was:
gethttp %HR_URL% -h
GOTO Done
:Done
REM End.
|
You can modify this file to call a batch file other than HfReport.CMD if you desire. For instance, you may want it to call HfReport-Emailer.CMD (described above). In this case, you probably also want to schedule HfReport-Download.CMD to run automatically (also described above).
|