Before the client's server cloth a go to write exe, always be turned off by others, depressed incomparable, so think of this exe into a Windows service forget, in the background run you will not go to shut it, so there is the following crawl pit experience.
System environment: Windows R2
1. SC command to create and delete Windows services
SC instruction Usage Reference SC Baidu Encyclopedia, here is not much to say. Add service according to SC instruction successfully, start service, error 1053: Service does not respond to start or control request in time. Oh, oh, ~~~~~~ .
Various Baidu, Google various changes can be determined that this is not a permissions issue, the initial estimate should be non-standard Windows service application, so it cannot start. Well, then I'll just have to change the other way. Fortunately, just in the search for solutions to find another way to achieve online, that is the following.
2. Create and delete Windows Services using Instsrv.exe and Srvany.exe
Really is artifact ah, the implementation method is as follows:
① download related tools, address: Pacific Download, unzip and put it in the disk you need, here I put the C:\tools
② run cmd as Administrator, enter the folder where the tool is located, such as: C:\tools
③ Execute command: C:\tools\instsrv.exe ServerName C:\tools\srvany.exe,servername is the name of the service you need to create.
④ registry modification, here my registry path and online said not the same, the path of the web is HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services, my path is hkey_local_machine\ System\controlset001\services. As for the reasons I am not happy to check, interested in the small partners can check out to tell me. Locate our service below the current path, and then right-click the new item with the name parameters. Select parameters, and then create a new two string value on the right. The first name is application, the value is: The application path, the second name is Appdirectory, and the value is: The directory where the application resides.
OK, so far you have successfully created the service and are working properly. If the startup service is unsuccessful, you can enter the system service, locate the ServiceName service, double-click the property to enter it, and set allow interaction with the desktop. Then start the service.
To remove a service using the Instsrv.exe program: enter "C:\tools\instsrv.exe ServerName remove" at the command line. Note that Instsrv.exe This program can also delete some system services, so please confirm the confirmation when using.
Why is this way EXE can be executed? The following Netizen's related statement (according to textual research should be this reason):
Instsrv.exe can create and delete services, however, if no srvany.exe is involved, the created service may not start. So what did Srvany.exe do, after starting the service we can find our service in Task Manager, then right click on the service, select Go to process, (if no item in the process is selected, click Show All user processes below and then select Go to process), we see the srvany.exe, not our Own EXE. Originally our EXE became a child of it, started by Srvany.exe help.
Ps:
1, SC command using the process of hollow lattice pit, SC [servername] Create Servicename [optionname= optionvalues], This optionname and optionvalues parameter allows you to specify the name and value of the action command parameter. Note that it is important that there are no spaces between the action name and the equals sign.
2, in the new registry when there is a pit, is 360, when the 360 when the registry key to change the name of application error: Registry Editor cannot be renamed
Reference from: http://www.cnblogs.com/jiaoyiping/p/5638506.html
About EXE applications made into Windows service crawl pits