Registering a batch file as a service is automatically invoked when the system is started

Source: Internet
Author: User
Tags jboss

  How to register a batch file as a service, automatically call the Startagent.bat script when the system is started, the following is the specific implementation process, the need for friends can refer to the following

Two days ago completed the Java program to register as a win service, now I have a Java project lifting contains the startup script Startagent.bat. The effect I want to achieve is to automatically invoke the Startagent.bat script when the system starts, and then start searching for relevant information online.     1, first by the senior prompts you can use System command SC to implement     SC Create service name binpath=. bat file path start=auto    (note = empty after , if the file path contains spaces in quotation marks)     specific parameters can be viewed by using SC/?     Installation is very smooth, the management/service in the new installed services, but the start of the error:    "On the local computer can not start the Server service, error 5: Access denied"     Delete Service when the use of &N Bsp   SC Delete Service name     ERROR: "XXX service has been marked for deletion"     Reinstall error:    "1053: Service did not respond to start or control request in time" &nbsp ;   tried, and every Netizen said this way is not workable, to start as a service. The bat file must conform to the specific format specified on MSDN.    --------------Try the new scheme--------------    adopt instsrv.exe/srvany.exe    with instsrv.exe/s Rvany.exe registered Windows Service method:    1. Registration Service: X:/XXX/INSTSRV Service name X:/xxx/srvany.exe (note that use "/")    --------to register Srvany.exe as system services     2. Regedit open registry     3. Enter hkey_local_machine/system/currentcontrolset/services/service name     4. Right-new-item fill 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-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   -----------is defined through Srvany.exe startup registry. EXE application     9. Start the service.     (Note: 7 and 8 essential)     in Windows Service Manager to see the defined service ...    problem resolved, however, there were strange 2 acts:    A, Starting and shutting down services in a service does not appear to be valid, only the reboot will take effect     B, the configuration file is restored every time? (estimated to be from one of their own minor modifications, to be identified ...)     finally through reconstruction to solve the B problem, why? My modifications?... ...     Remove a custom service?    If you want to uninstall a local service, you can enter the following command from the command line     SC Delete servicename    or directly modify registry     Delete the corresponding key value in Hkey_local_machine/system/currentcontrolset/services.    
Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.