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.

Sonntag, 23. März 2008

Learn Windows Scripting Act 2 - Class material

Class material used in 'Learn Windows Scripting Act 2'

Win32_Service Class

Microsoft Scriptomatic Tool

Complete Script

On Error Resume Next

strComputer = Wscript.Arguments(0)

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Service where DisplayName = ""MSSQLSERVER""")
For Each objItem in colItems

Wscript.Echo "DisplayName: " & objItem.DisplayName
Wscript.Echo "StartMode: " & objItem.StartMode
Wscript.Echo "State: " & objItem.State
star = Wscript.Arguments(1)
ret2 = objitem.ChangeStartMode(star)
ret = objitem.StopService()

Wscript.Echo ret
Wscript.Echo ret2


Keine Kommentare: