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'

References:
Win32_Service Class
http://msdn2.microsoft.com/en-us/library/aa394418(VS.85).aspx

Microsoft Scriptomatic Tool
http://www.microsoft.com/technet/scriptcenter/tools/scripto2.mspx



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



Next

Keine Kommentare: