windows-service – 如何从脚本重新启动Windows服务?
发布时间:2021-05-15 23:14:59 所属栏目:Windows 来源:网络整理
导读:我有一个批处理脚本,如下所示: sc stop myservicesc start myservice 它出错了,因为sc不会等到服务停止.如何使用脚本重新启动服务? 海报希望确保在尝试重新启动服务之前停止服务.您可以在“sc query”的输出上使用循环,执行以下操作: :stopsc stop myserv
我有一个批处理脚本,如下所示: sc stop myservice sc start myservice 它出错了,因为sc不会等到服务停止.如何使用脚本重新启动服务? 海报希望确保在尝试重新启动服务之前停止服务.您可以在“sc query”的输出上使用循环,执行以下操作::stop sc stop myservice rem cause a ~10 second sleep before checking the service state ping 127.0.0.1 -n 10 -w 1000 > nul sc query myservice | find /I "STATE" | find "STOPPED" if errorlevel 1 goto :stop goto :start :start net start | find /i "My Service">nul && goto :start sc start myservice (编辑:辽源站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐
- Windows VPN服务器可以与VPN客户端通信,但不会将
- “用户组”在Linux上到底是怎么工作的?
- 如何在Windows 10中完全卸载Internet Explorer
- 关闭最后一个后,在Windows 2012 Server核心上打开
- windows – IPv6链路本地地址格式
- windows-server-2003 – FreeBSD主机ZFS在Root上
- windows-server-2012-r2 – 禁用Windows 2012 R2
- Windows 11新版起始推送!新特性和修复问题一览
- 微软不受支持Win11 PC电脑获累积更新补丁 坚持最
- 如何在Windows 10上使用Windows Update目录驱动程
热点阅读