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

Enable Remote Registry 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.ReadAll
objFile.ClosearrComputers = Split(strComputers, vbCrLf)
For Each strComputer In arrComputers Set wbemServices = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set wbemObjectSet = wbemServices.InstancesOf("Win32_Service")
For each wbemObject in wbemObjectSetif wbemObject.DisplayName = "Remote Registry" and wbemObject.State = "Stopped" then errRec = wbemObject.ChangeStartMode("Automatic")
errRec = wbemObject.StartService()
WScript.Echo "Changed RemoteRegistry Service on Computer: "& strComputer else
end if
if wbemObject.DisplayName = "Remote Registry" and wbemObject.State = "Running" then WScript.Echo "RemoteRegistry Service already running on Computer: "& strComputerelse
end if
Next 'created by Julian Ruf

Keine Kommentare: