The batch file registered as a service

  
        I registered the java program as a win service two days ago. Now I have a java project lifting that contains the startup script startagent.bat. The effect I want to achieve is: the startagent.bat script is automatically called when the system is started, so I start to seek relevant information online. 1, first by the brothers suggest you can use the system command sc to achieve sc create service name binPath = .bat file path start = auto (note = there are spaces behind, if the file path contains spaces, use quotes) Specific parameters can be used Sc /? to view. Installation is quite smooth, there is a new installation service in the management /service, but the error is reported when starting: "The local computer can not start the server service, error 5: refuse access" when deleting the service using the sc delete service name error: & ldquo; xxx service has been marked as deleted " reinstallation error: & rdquo; error 1053: the service did not respond in time to start or control request "try unsuccessful, and every netizen said this way does not work, to start as a service.bat files have to meet certain prescribed format on the msdn. & Mdash; & mdash; & mdash; & mdash; & mdash; & mdash; & mdash; & mdash; & mdash; & mdash; & mdash; & mdash; & mdash; & mdash; try the new program & mdash; & mdash; & mdash; & mdash; & mdash; & mdash; & mdash; & mdash; & mdash; ————— Use instsrv.exe /srvany.exe to register windows service methods with instsrv.exe /srvany.exe: 1. Registration service: x:/xxx/instsrv service name x:/xxx/srvany .exe (note using "/") -------- Register srvany.exe as a system service 2. regedit to open the registry 3. Enter HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/service name 4. Right click - New - Entry in Parameters 5. Open Parameters, right-click - New string value Application 6. Double-click Application to fill in the absolute path of the application, such as: E:/jboss-4.0.5.GA/bin/starteos.bat 7. Right-click - New - String value AppDirectory 8. Double-click AppDirectory to fill in the application's working directory, such as: E:/jboss-4.0.5.GA/bin ----------- .exe application to start over srvany.exe defined in the registry 9. Start the service. (Note: 7 and 8 are indispensable) See the defined service in the Windows Service Manager... The problem is solved, but there are strange two scenes: A. Starting and shutting down the service in the service seems to be invalid, only The restart will take effect B. Is the configuration file restored every time? (The estimate is a minor modification from oneself, to be ascertained...) Finally, the B problem is solved through reconstruction. Why? I modified? ... ... Delete a custom service? If you want to uninstall a local service, you can enter the following command via the command line sc delete ServiceName or modify the registry directly in HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services delete the corresponding key value.
Copyright © Windows knowledge All Rights Reserved