使用以下命令在 cmd 中创建了一个服务
c:\>sc create "DellCare" start= auto displayname= "DellCareService" binpath= "C:\Users\Dev Parzival\Desktop\bat\DellCare\DellCare.bat"
[SC] CreateService SUCCESS
当我重新启动笔记本电脑时,DellCare服务没有启动。
c:\>sc query DellCare
SERVICE_NAME: DellCare
TYPE : 10 WIN32_OWN_PROCESS
STATE : 1 STOPPED
WIN32_EXIT_CODE : 1077 (0x435)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x0
DellCare.bat
@echo on
cd /D E:\code\pro\DellCare\out
echo Present working directory - %cd%
java --module-path "C:\thirdparty\javafx-sdk-14.0.1\lib;E:\code\pro\DellCare\out;" --add-modules javafx.controls,javafx.graphics -cp ".;C:\thirdparty\javafx-sdk-14.0.1\lib\*" dellcare.mainclass.MainClass
当我尝试手动启动服务时,它给出了错误
C:\WINDOWS\system32>sc start dellcare
[SC] StartService FAILED 1053:
The service did not respond to the start or control request in a timely fashion.
然后访问了这个链接并最终在HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control中创建了ServicesPipeTimeout ,但是当我启动 dellcare 服务时,它仍然给出了相同的错误,即服务没有及时响应......
为什么 DellCare 服务未启动以及如何解决?
提前致谢。
据我所知,Windows 服务通常需要一些额外的配置,而不是一个命令行。
If you try to open
Services
byservices.msc
and start the service just created manually, the following message should appear:If you only need to run a certain script each time Windows starts (for the current user), you can copy the
.bat
file and paste its shortcut into"%AppData%\Microsoft\Windows\Start Menu\Programs\Startup"
. Another approach to accessing it is to typeshell:startup
in the Explorer address bar.Next time the current user logins in, the script will be run automatically. You can check it's added and enabled via
Task Manager -> Startup
.You can't run just any
exe
orbat
as a service, because a system service is specifically written to interface with Windows via a special protocol, which is used by thesc
command.Services are generally written as console applications with the entry point for a console application as the main function, started by its Service Entry Point and continuing with the ServiceMain Function.
You may however encapsulate a program or batch file using a program that does implement the required protocol.
You may use:
Last update from 2017.