The Registry item's description of the start parameter has always been wrong. I even wrote a wrong program to disable some self-start items at the same level.

Source: Internet
Author: User

After installing a lot of software, there will be a lot of self-starting service items, even as high as 50 items.

 

Because my machine is fond of some inexplicable errors, some programs cannot be used. Later, I had to reinstall the system to solve the problem. I simply wrote a program and disabled it.

 

I didn't expect that the startup was disabled. The online explanation turned out to be "loaded by the core loader", but it was dizzy. However, after the threshold was set to 0, it could not be started, but it is a hidden danger.

 

Start = {0, 1, 2, 3, 4}
0 = loaded by the core Loader
1 = loaded by the I/O subsystem
2 = auto start
3 = manual start
4 = start prohibited

 

It seems that the program will stop the service first, and then start it manually.

 

Let's take a look at the start REG_DWORD description of the registry:

========================================================== ========================================================== ===

 

Windows XP System Service

Many system services are automatically started when the system is started for hardware drives, memory management, network services, and other services. Services. MSC is the service manager that comes with Windows systems. Net commands are the corresponding command line tools.
Net

Services. MSC is a graphical interface, which can be understood without any details. Net, the most commonly used one, is the two commands that I will use below: Start and Stop.

Net start servicename // start a registered service based on the service name in the parameter. if the service name is not registered, an error is returned.

Net stop servicename // stop a service

Registry

Service-related registry directory:

HKEY_LOCAL_MACHINE/system/controlset001/services
HKEY_LOCAL_MACHINE/system/controlset002/services
HKEY_LOCAL_MACHINE/system/CurrentControlSet/services

You can find the various services registered in the system in these three places. Manually register the service from here, and I chose the last directory.

First, check the registered service. We can see that each service exists as a separate node. Some key values in the node describe the information and configuration of the service, the most important ones are:
Name type data
Displayname REG_SZ: the service name registered. It is used to uniquely identify a service under net. For example, we use cliff
Description REG_SZ description
Absolute path of the executable file of the ImagePath reg_expand_sz Service
Start REG_DWORD start mode. Optional values include 0, 1, 2, 3, and 4.
Type REG_DWORD program type, 0x10 and 0x20
Errorcontrol REG_DWORD error handling

Displayname, start, and ImagePath are the most important values in the preceding table. Here we further describe the value types of start:

Start = {0, 1, 2, 3, 4}
0 = loaded by the core Loader
1 = loaded by the I/O subsystem
2 = auto start
3 = manual start
4 = start prohibited

Therefore, we can create our own services following this structure:

If you are careful, you may find that there are two nodes in inetsvr. You did not make a mistake. Here I am a little lazy and didn't show you the manual registration service, instead, it intercepts a service registered using the method mentioned later. However, if you manually register the service, you can not create the two subnodes. Later we will see that they are all automatically created by the system, so don't worry.

After the creation, you are eager to open services. msc, but you have not found the service name cliff you just registered, which means you will not be able to enjoy the service that cliff brings to you! Don't worry. restart the system and try again. You will find that it is waiting for you quietly.

Now, we can manually register system services. But we also find that there is a bad thing, that is, we need to restart the system. Think back to the tomcat, MySQL, and other stuff that you may have installed, and you have registered services without restarting the system. How can we achieve this?
INF

INF: device information file

Prerequisites: INF

Here we need three INF files, one for registering and starting the service, one for stopping and canceling the service, and the last for adding a function menu when inserting a USB flash drive.

The first thing to note is that the final implementation is somewhat different from my original vision. At first, we wanted the USB flash drive to automatically run the batch file after loading, which should be like this:

[Autorun]
Open = setup. bat

However, the test showed that the operation was not successful, so the second solution was adopted, which is also a relatively easing solution: add the setup dB and unistall dB options to the menu of the USB flash drive.
Adddb. inf

[Version]
Signature = "$ Windows NT $"
[Defainstall install. Services]
Addservice = inetsvr, my_addservice_name
[My_addservice_name]
Displayname = firebirdserver
Description = Mobile DB Server
Servicetype = 0x10
Starttype = 3
Errorcontrol = 0
Servicebinary0000000001108binfbserver.exe-R

Deldb. inf

[Version]
Signature = "$ Windows NT $"
[Defainstall install. Services]
Delservice = inetsvr, my_delservice_name
[My_delservice_name]
Displayname = firebirdserver

Bat batch processing

Finally, I want to achieve the goal of automatically registering the service and starting the service after the USB flash drive is inserted. The infers created by the pipeline can complete the registration service, and the adjustment can be completed with the rundll32.exe configuration with the corresponding parameters. Therefore, the. bat batch file contains only two lines of text:

@ Rundll32.exe setupapi, installhinfsection defaultinstall 132. firebird_2_0adddb.inf
@ Net start firebirdserver

Note: The previous @ is to not display the execution process of the two statements, but the pop-up black box still cannot be avoided for the time being. You need to find a further method.

On the other hand, in order to restore the Registry when removing the USB flash drive, an uninstall. bat is also required. It also calls an INF, but it should be noted that the service should be stopped first!

@ Net stop firebirdserver
@ Rundll32.exe setupapi, installhinfsection defaultinstall 132. firebird_2_0deldb.inf

Wait a moment. Now these two BAT files can automatically register, start, stop, and log out of the service, but we forget one thing, that is, let him run automatically! The following file, which is often associated with viruses, will appear ---- autorun. inf !!
Autorun. inf

[Autorun]
Shell1 = open
Shell1commandancer.exe
Shell2 = setup DB
Shell2command = setup. bat
Shell3 = uninstall DB
Shell3command = Uninstall. bat

The shell command is used to add a new entry in the right-click menu. The shell sequence number indicates the order of the entry to be added, but it seems to be a relative order and will be added to the initial position, in addition, the first line is automatically set to open on both servers, which is why the shell1 line is added. To retain the original double-click function, you must manually call assumer.exe. ''Indicates that the current path is opened. If no parameter exists, my documents of the current user will be opened.
Conclusion

So far, everything has been done. Let's sort out the directory structure of the USB flash drive:

Root
| ---- Autorun. inf
| ---- Setup. bat
| ---- Uninstall. bat
| ---- Firebird_2_0
| ------- Adddb. inf
| ------- Deldb. inf

A total of three INF and two bat are used to register, start, stop, and uninstall system services by right-clicking the menu.

 

 

========================================================== ========================================================== ===

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.