Windows Scripting BLOG

Due to limited time working on this project this place is not intended to people who are new to scripting but much more for people who are already familiar with the VBS/WMI syntax.

Donnerstag, 17. Mai 2007

Stop/Disable Windows Service

On Error Resume NextIN_FILE = Wscript.Arguments(0)
Const PRO_READ = 1Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(IN_FILE, PRO_READ)
strComputers = objFile.ReadAllobjFile.ClosearrComputers = Split(strComputers, vbCrLf)
For Each strComputer In arrComputersSet wbemServices = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set wbemObjectSet = wbemServices.InstancesOf("Win32_Service")
For each wbemObject in wbemObjectSetif wbemObject.DisplayName = "Computer Browser" then
errRec = wbemObject.StopService()
errRec = wbemObject.ChangeStartMode("Disabled")
WScript.Echo "Changed Computer Browser Service to Stopped/Disabled on Computer: "& strComputerelse
end if
'created by Julian Ruf

Keine Kommentare: