- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
在windows下编写启动服务的脚本
在windows下编写启动服务的脚本由于一些服务只有在特定的时候才会使用到,所以就想到写一个脚本来手动启动服务,而不用在开机的时候自动启动。?使用命令行启动服务在cmd下可有两种方法打开,net和sc,net用于打开没有被禁用的服务,语法是:net start 服务名net stop 服务名用sc可打开被禁用的服务,语法是:sc config 服务名 start= demand???? //手动sc condig 服务名 start= auto?????? //自动sc config 服务名 start= disabled //禁用sc start 服务名sc stop服务名注:1)服务名不一定是你在服务面板看到的那个名,例如,你要打开被禁用的telnet服务,sc config telnet start= auto,报错:[SC] OpenService FAILED 1060,因为telnet的服务名不是telnet而是tlntsvr, sc config tlntsvr start= auto就OK了,在服务面板里查看telnet属性,从可执行文件的路径里可看到服务程序名,即命令中的服务名。 2)start=后面有空格,少了就有错sc.exe命令功能列表: 注:以下命令中。=号后面都有一个空格,=号前面没有空格! 1.更改服务的启动状态(这是比较有用的一个功能) 2.删除服务(除非对自己电脑的软、硬件所需的服务比较清楚,否则不建议删除任何系统服务,特别是基础服务) 3.停止或启动服务(功能上类似于net stop/start,但速度更快且能停止的服务更多) 具体的命令格式如下: 修改服务启动类型的命令行格式为(特别注意start=后面有一个空格) sc config 服务名称 start= demand(设置服务为手动启动) sc config 服务名称 start= disabled(设置服务为禁用) 停止/启动服务的命令行格式为 sc stop/start 服务名称 注意:平时常接触的都是服务的显示名称,而以上所指是服务名称,都可以在控制面板-管理工具-服务里面,双击对应的服务来查询。 先举例说明一下具体的设置方法: 如设置远程注册表服务为手动其格式为 sc config RemoteRegistry start= demand 设为禁用的格式为: sc config RemoteRegistry start= disabled 停止服务则格式为: sc stop RemoteRegistry 首先把自己所需设置的服务名称查到之后,按照上面的格式做成批处理文件,重装系统之后只要运行批处理文件即可。 以下是我的设置,以XpSp2为蓝本,可比对所用的系统进行增删和修改。注:未加入XpSp2的自动更新、安全中心、防火墙。 sc config Alerter start= demand sc config TrkWks start= demand sc config helpsvc start= demand sc config policyAgent start= demand sc config dmserver start= demand sc config WmdmpmSn start= demand sc config Spooler start= demand sc config RemoteRegistry start= demand sc config NtmsSvc start= demand sc config seclogon start= demand sc config Schedule start= demand sc config WebClient start= demand sc config W32Time start= demand sc config WZCSVC start= demand sc config ERSvc start= demand sc config Themes start= demand sc config FastUserSwitchingCompatibility start= disabled sc config Messenger start= disabled sc config protectedStorage start= disabled sc config SSDpSRV start= disabled sc config TermService start= disabled sc config Sh
文档评论(0)