Some people use batch files to automatically install windows patches, but because Windows mainly has 2 different patches and different parameters, if the parameters are wrong, it will not be installed, so it is different. Patches require different parameters. I will come to the specific analysis below.
I put Windows 2003 server patch file in the same directory, you can clearly see the patch file name in front of the icon there are two types, one is a simple executable file icon, another Is an icon that marks the executable file of the compressed file.
WindowsServer2003-KB823559-x86-ENU.exe file icon is a simple executable file icon, as shown in the update.png, view the help information of the patch, you can see WindowsServer2003-KB823559-x86- ENU is using Microsoft's update program to install the patch. From the figure KB823559ver.png, check the version information of the patch. It can be seen that the WindowsServer2003-KB823559-x86-ENU patch is from SFXCAB.EXE, all others have Patches for icons for common executables have similar properties.
DirectX9-KB819696-x86-ENU.exe file icon is an icon of the executable file that marks the compressed file, as shown in the figure directx9.png, to view the help information of the patch, the parameters it knows Excluding /U and /Z, if you use the /U parameter to run it will generate an error, as shown in error.png. As shown in the directx9ver.png, check 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 files that mark the compressed file. They all have similar properties.
now clear the Windows there are two different kinds of patches, use a different patch, the required parameters are not the same.
So how do you distinguish between the two different kinds of patches of it in a batch file? The safest way is to find a small program that can detect the resource information of the patch file. If the resource of the patch includes an icon of the executable file that marks the compressed file, then the patch is the second type of patch, using only the /Q parameter. If the patch does not include an icon in the resource, then it is the first type of patch. You can use the /U /Q /Z parameter to install the patch.
Here I give a simpler way, just use the internal commands of Windows, no need for additional programs, is to find the feature string in the patch file, if a string exists only in a certain type of patch We can use this to distinguish the type of patch.
As shown in the character string .png, use the text editor to open the WindowsServer2003-KB823559-x86-ENU.exe file and the DirectX9-KB819696-x86-ENU.exe file respectively, you can find many feature strings, such as the string " _SFX_CAB_EXE_PATH" only exists in the patch of type SFXCAB.EXE, while the strings "CABINET" and "WEXTRACT" only exist in the patch file of type WEXTRACT.EXE. So you can use the method of finding the string to determine the type of the patch file.
The following command can indicate the parameters required by the patch file: (@findstr _SFX_CAB_EXE_PATH patch file name > nul && @echo parameter /U /Q /Z) |
|
The @echo parameter /Q
The above command 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.
The results are shown in the figure findstr.png.
Finally, give the complete batch command:
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, do not need to concentrate the patch files in the same directory, /R for the command The parameters will automatically search all subdirectories.
Note that for the 2002 and December patches, basically do not need to use the qchain command, the new patch has built-in this command.