批处理文件以在Windows Server 2003中启用服务

时间:2022-12-20 02:17:31

A windows service in windows server 2003 keeps on disabling every day. I want to write a batch file which would check the status of the service and start it if its not running. I did that with the following command

Windows Server 2003中的Windows服务每天都在禁用。我想编写一个批处理文件来检查服务的状态,如果它没有运行就启动它。我用以下命令做到了

Net Start "Service_Name"

It works fine in starting a service whose Startup Type is either "Automatic" or "Manual" and does not start a service whose Startup Type is "Disabled"

它可以正常启动一个服务,其启动类型是“自动”或“手动”,并且不启动其启动类型为“已禁用”的服务

I tried the following command

我尝试了以下命令

enable "SERVICE_NAME" SERVICE_AUTO_START

But this command is not supported by Windows Server 2003. Can you guys help me as which command to be used to enable a service in Windows Server 2003?

但Windows Server 2003不支持此命令。您能帮助我在Windows Server 2003中使用哪个命令来启用服务吗?

Thanks in advance.

提前致谢。

1 个解决方案

#1


0  

I can't confirm this works for Server 2003 but it works for Win7, so worth a shot.

我无法确认这适用于Server 2003,但它适用于Win7,所以值得一试。

sc config "Service_Name" start= auto
net start "Service_Name"

#1


0  

I can't confirm this works for Server 2003 but it works for Win7, so worth a shot.

我无法确认这适用于Server 2003,但它适用于Win7,所以值得一试。

sc config "Service_Name" start= auto
net start "Service_Name"