新人诚心求教,如何用vbscript修改windows服务的启动状态
新人诚心求教,如何用vbscript修改windows服务的启动状态,例如‘我想把服务状态从"手动"改成"无效"或者"禁止",请教高手,
环境必须是windows2000,拜托啦!
[解决办法]
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
以上是修改所有手动启动为禁用,可以据些修改