vbscript save wmi to xml

Dragonlord

New Member
Please need help. My script is\[code\] Set objService = GetObject("winmgmts:\\.\Root\CIMV2") Set colListOfServices = objService.ExecQuery _ ("Select * from Win32_Service Where StartMode = 'Auto' AND Started = false") For Each objService in colListOfServices WScript.Echo Date & " " & Time & objService.Caption Set xmlDoc = _ CreateObject("Microsoft.XMLDOM") XMLDoc.async = False Set objRoot = _ xmlDoc.createElement("ServerCheck") xmlDoc.appendChild objRoot Set objRecord = _ xmlDoc.createElement("Services") objRoot.appendChild objRecord For Each objName in colListOfServices Set objName = _ xmlDoc.createElement("Name") objName.Text = objService.Caption objRecord.appendChild objName Next Set objDate = _ xmlDoc.createElement("Date") objDate.Text = Date & Time objRecord.appendChild objDate Set objIntro = _ xmlDoc.createProcessingInstruction _ ("xml","version='1.0'") xmlDoc.insertBefore _ objIntro,xmlDoc.childNodes(0) xmlDoc.Save "C:\Users\111\Desktop\Audits.xml" Next\[/code\]And my XML\[code\]Services><Name>Windows install</Name><Name>Windows install</Name><Name>Windows install</Name><Date>25.12.201215:51:19</Date>\[/code\]WScript.Echo(to test) give me 3 different stopped serveces. But in my XML save only one service in 3 copys.How can I save in XML all stopped services right?
 
Back
Top