Depth description Win 2003 automatic upgrade patch function

  
Some readers have reported problems with batch Windows auto-upgrade files. Some patch packages have an error message during installation and cannot be continued.
After research, it was found that this is because Windows mainly has two different types of patches, which need to use different parameters. Once the parameters are wrong, it will not be installed, so different parameters need to be used for different patches. Let's analyze it in detail.

from the picture to see the patch type

shown in Figure 1, the Windows 2003 Server patch file in the same directory,
can clearly see the patch file name in front of the icon there are two Types, one is a simple executable file icon, and the other is an executable file icon that marks a compressed file.

From the attribute analysis format

The icon of the WindowsServer2003-KB823559-x86-ENU.exe file is a simple executable file icon. You can see the help information for this patch from Figure 2 and found that it uses the Microsoft update program to install the patch. The version information of the patch can be viewed from Figure 3. It is made by SFXCAB.EXE, and all other patches with common executable file icons have similar properties.


The icon of the DirectX9-KB819696-x86-ENU.exe file is an executable file icon that marks the compressed file. You can view the help information of the patch. The parameters it recognizes do not include /U and /Z, and if you use the /U parameter to run it will generate an error. Similarly, looking at the version information of the patch, it can be seen that the DirectX9-KB819696-x86-ENU patch is derived from WEXTRACT.EXE, and all other patches with executable file icons with flag compressed files have similar characteristics. .

is now clear that there are two different types of Windows patches, use a different patch, need parameters are not the same. How

automatically distinguish between patch format

differentiate between the two different patches of it in a batch file? The most secure way is to find a small program to detect the patch file resource information. If the patch resource includes an executable file icon that marks the compressed file, then the patch is the second type of patch, only the /Q parameter is used, if the patch resource is Excluding the icon, then the first type of patch, you can use the /U /Q /Z parameters to install the patch.

Here is an easier way, using only Windows internal commands, no additional procedure. Find the feature string in the patch file. If a string exists only in a certain type of patch, you can distinguish the type of patch based on this.

Step 1: As shown in Figure 4, use the text editor to open the WindowsServer2003-
KB823559-x86-ENU.exe file and the DirectX9-KB819696-x86-ENU.exe file, you can find many characteristic characters. Strings such as the string "_SFX_CAB_EXE_PATH" exist only in the patch of the SFXCAB.EXE type, while the strings "CABINET" and "WEXTRACT" exist only in the patch file of the WEXTRACT.EXE type. So you can use the method of finding a string to determine the type of patch file.





Step 2: Enter “cmd” in the “Start→Run” menu, then enter the folder where the patch is located and run the following command to indicate the Parameters required for the patch file:

(@findstr _SFX_CAB_EXE_PATH patch file name >nul && @echo parameter /U /Q /Z) @echo Parameter /Q

The above command This means that if the string _SFX_CAB_EXE_PATH is found, the patch uses the /U /Q /Z parameter, otherwise the /Q parameter is used.

Step 3: Run 5 shows the results.


Simple method once and for all

If you first identify the judgment, then add the parameters according to the results, and then run the batch processing, it is too much trouble. Here is a complete batch command that combines the judgment and installation of the patch:
FOR /R %%F IN (*.exe) DO @((@findstr _SFX_CAB_EXE_PATH "%%F" >nul && @start /wait %%F /U /Q /Z ) @start /wait %%F /Q )
qchain.exe

Put the batch file in the patch directory, You don't need to group the patch files into the same directory. The /R parameter of the for command will automatically search all subdirectories. Note: For the patch after December 2002, basically do not need to use the qchain command, the new patch has built-in this command.

Copyright © Windows knowledge All Rights Reserved