In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article is about how to register a batch file as a service that is automatically invoked when the system starts. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Two days ago, I finished registering the java program as a win service. Now I have a java project crane with a startup script startagent.bat. What I want to achieve is to automatically call the startagent.bat script when the system starts, so I start to look for relevant information on the Internet.
1. First of all, it can be realized by the elder brother using the system command sc.
Sc create service name binPath= .bat file path start=auto
(note = followed by a space, enclosed in quotation marks if the file path contains a space)
For specific parameters, you can use sc /? To check it out.
The installation went well, and a newly installed service appeared in the administration / service, but an error was reported at startup:
"unable to start server service on local computer, error 5: access denied"
Use when deleting a service
Sc delete service name
Error: "xxx service has been marked for deletion"
Reinstall error:
Error 1053: the service did not respond to startup or control requests in a timely manner
The attempt failed, and some netizens said that this method would not work, if they wanted to start as a service. The bat file must conform to the specific format specified on the msdn.
-try a new solution-
Using instsrv.exe / srvany.exe
Register the windows service with instsrv.exe / srvany.exe method:
1. Registration service: x:/xxx/instsrv service name x:/xxx/srvany.exe (note the use of "/")
-registering srvany.exe as a system service
2. Regedit opens the registry
3. Enter the HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/ service name
4. Right-create-enter Parameters for the item
5. Open Parameters, right-create-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-create-string value AppDirectory
8. Double-click AppDirectory to fill in the working directory of the application, such as E:/jboss-4.0.5.GA/bin
-launch the defined in the registry through srvany.exe. Exe application
9. Start the service.
(note: 7 and 8 are indispensable)
See the defined service in the windows service manager.
The problem was solved, but there were two strange acts:
A. Starting and shutting down the service seems to be invalid, and only restart will take effect.
B. Is the configuration file restored every time? (it is estimated that it comes from a small change of its own, which remains to be found out. ... )
In the end, problem B is solved through reconstruction. Why? My revision?... ...
Delete a custom service?
If you want to uninstall a local service, enter the following command from the command line
Sc delete ServiceName
Or directly modify the registry.
Delete the corresponding key value in HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services.
Thank you for reading! This is the end of this article on "how to register a batch file as a service to be automatically invoked when the system starts". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 291
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.