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.

Mittwoch, 2. April 2008

Learn Windows Scripting Act 4 - Class material

Class material for ACT 4


Split Method

Open Text File

Complete Script

On Error Resume Next

IN_FILE = "test.txt"
Const PRO_READ = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(IN_FILE, PRO_READ)
strComputers = objFile.ReadAll
arrComputers = Split(strComputers, vbCrLf)

For Each strComputer In arrComputers

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

For Each objItem in colItems

ret = objitem.StopService() & " on Computer " &

Wscript.Echo ret



* Loop routine wrapped around the core script
* Core script wrapped into the Loop routine

Keine Kommentare: