当前位置: 代码迷 >> vbScript >> 新人诚心求教,怎么用vbscript修改windows服务的启动状态
  详细解决方案

新人诚心求教,怎么用vbscript修改windows服务的启动状态

热度:3721   发布时间:2013-02-26 00:00:00.0
新人诚心求教,如何用vbscript修改windows服务的启动状态
新人诚心求教,如何用vbscript修改windows服务的启动状态,例如‘我想把服务状态从"手动"改成"无效"或者"禁止",请教高手,
环境必须是windows2000,拜托啦!

------解决方案--------------------------------------------------------
VBScript code
Set oWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")Set colServices = oWMIService.ExecQuery("Select * from Win32_Service where Name='NetLogon'")For Each oService In colServices    With oService        If .StartMode = "Manual" Then iRet    = .ChangeStartMode("Disabled")    End WithNext
------解决方案--------------------------------------------------------
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colServiceList = objWMIService.ExecQuery _
("Select * from Win32_Service where StartMode = 'Manual'")

For Each objService in colServiceList
errReturnCode = objService.Change( , , , , "Disabled")
Next

以上是修改所有手动启动为禁用,可以据些修改
  相关解决方案