How to make your own Windows Service

  

As a Windows system administrator, installing secure HotFix should be no stranger. Every time we install a machine, we always download countless patches, but the annoying thing is to install one each time. The HotFix system will Reboot once. Of course, before Reboot, we don't click the "OK" button. After installing other patches directly, Reboot is not bad, but it seems a bit less professional. Today I teach you to make a service of your own. Pack, you can install the patch you need to install in one installation, it seems to be very cool ~

In order to test, I chose a Chinese version of Windows 2000 Server, and we need to install 2 security patches ( Of course, more than this, for example, one is the Windows 2000 input method vulnerability patch (Q270676), one is the named pipe patch (Q269523).

Follow me to do it:

1, download the HotFixs we need to install, http://download.microsoft.com/download/win2000platform/Patch/Q269523/NT5/CN/Q269523_W2K_SP2_x86_CN.EXE and http://download.microsoft.com/download/win2000platform/Patch/q270676/NT5/CN/Q270676_W2K_SP2_x86_EN.EXE.

2, switch to CMD mode, create a hotfix directory on the C drive, and then execute

Q269523_W2K_SP2_x86_CN.EXE /x (recommended order of unpacking according to the size of Q, from small To the big, the reason I will mention later)
Enter the prompt "C:Hotfix" after entering the prompt to enter the unpacking path.

C:>cd hotfix

C:hotfix>dir
The volume in drive C is the serial number of the C
volume is AC58-F7F5

C:hotfix directory

2001-05-04; 04:00;;;;<DIR>
2001-05-04; 04:00;;;;<DIR>.. BR>2000-08-14; 18:57;;;;98,064 hotfix.exe
2000-08-14; 18:57;;;;15,139 hotfix.inf
2000-08-14; 17: 19;;;835,856 kernel32.dll
2000-08-14; 17:19;;;;85,776 services.exe
2000-08-14; 18:31;;;;88,245 sp2.cat
2000-08-14; 18:57;;;;;3,584 spmsg.dll
2001-05-04; 04:00;;;;<DIR>symbols
2001-05-04; 04:00 ;;;;<DIR>uniproc

Then we will copy the hotfix.inf file.
C:hotfix>copy hotfix.inf q269523_en.inf
1 file has been copied.

Next we unpack the second HotFix,
Q270676_W2K_SP2_x86_CN.EXE /x
Enter "C:Hotfix" after seeing the prompt to enter the unpacking path.
Also copy a copy of the hotfix.inf file at this time.
C:hotfix>copy hotfix.inf q270676_cn.inf
has copied 1 file.

The third and fourth........ Repeat the same operation.

3. At this point, we have unpacked the HotFix files into the C:Hotfix directory, and with the copy of each HotFix inf file, we will analyze these inf files now, generally we will finally unpack them. The inf file is used as a template. Because the inf file is divided into many fields, from the results of my observation, the fields of the inf file may increase over time, which is why we started unpacking in order of Q size. In the example, we use the inf file of Q270676 as the template. We edit the hotfix.inf file. This file already contains the information of Q270676. We just need to add the information in Q269523 to the file. Let's analyze the inf file of Q269523. Content:

Most of the previous ones are basically similar, we only search for some unique fields.

[MustReplace.System32.files]
SERVICES.EXE
[CopyAlways.DriverCab.files]
kernel32.dll
[Cache.files]
SERVICES.EXE < BR>KERNEL32.DLL
[Uniprocessor.Kernel.files]
KERNEL32.DLL, UNIPROCKERNEL32.DLL
[Multiprocessor.Kernel.files]
KERNEL32.DLL
[SourceDisksFiles]
SERVICES.EXE=1
UNIPROCKERNEL32.DLL
KERNEL32.DLL=1

Then we search for the MustReplace.System32.files in the hotfix.inf file, and then add a line
SERVICES.EXE < BR> For the convenience of the future, we usually add some comments. The MustReplace.System32.files field of the edited hotfix.inf file looks like this:

[MustReplace.System32.files]

Q269523; Added by Adam
SERVICES.EXE

Next search for CopyAlways.DriverCab.files, Cache.files, Uniprocessor.Kernel.files, Multiprocessor.Kernel.files, SourceDisksFiles, and corresponding Add the information to the hotfix.inf file, and also pay attention to add the necessary comment file. The symbol indicating the comment in the inf file is a semicolon. Of course, we also recommend that you also comment on the necessary items in the template file, such as the Cache.files included in the two hot fixes. After we modify it, it becomes:

[Cache.files] < Br>

Q269523; Added by Adam
SERVICES.EXE
KERNEL32.DLL

Q270676; Added by Adam
winzm.ime
winsp.ime
winpy. Ime
wingb.ime
winabc.ime

In fact, at this point, we can already use our good stuff, but for the convenience of the future, we must modify some displays. Information, this is the Strings field in the inf file. We can see the Strings field at the end of the inf file, we have to modify some of the necessary information here.

First modify the Q number (not the OICQ number), change the Q number to your favorite 6 digits. Of course, you can enter other characters, but it may conflict with some software that checks HotFix. Or use the 6-digit number, and then modify the Comments, we paste the Comment of Q269523, you can also add some of your own description, the modified Strings field will become the following:

[Strings]

LangTypeValue=4
ServicePackSourceFiles="Windows 2000 Hotfix Source File"
HOTFIX_NUMBER="Q123456"
SERVICE_PACK_NUMBER=1
COMMENT="Windows 2000 Hotfix (Pre-SP2) [ ,null,null,3],See Q270676 for more information] This Fix Corrects the IME Problem...Windows 2000 Hotfix (Pre-SP2) [See Q269523 for more information] This Fix Corrects the NamePipe Problem..."

This is also convenient for us View the installed patches in the future.

4, well, we have already finished the modification. We started to install our own service pack. In fact, we only need to execute HotFix.exe, it will find the inf file by itself, then You will see a progress bar copying the file, then the system asks you to Reboot, click "OK", reboot, and our HotFix is ​​installed.

5, finally we can look at the effect, you can go to see the registry: HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionHotFix

You will find that you installed Q123456 squatting there~ very fulfilling oh ~

After summing up: After each new HotFix, you will add the file to your SP package, and then modify your inf file, you can ignore the fact that Microsoft is still for you. The release of the new SP (NT 4 SP 7 is gone), of course, the SP not only contains security patches, but also other aspects of the system have been improved, after all, the Tu eight road is still not comparable to the regular army. ;

Copyright © Windows knowledge All Rights Reserved