sorting - VBScript WQL Sort Result Set? -
apparently wql not contain order by
clause. there way sort result set based on 1 of columns? example:
set objwmiservice = getobject("winmgmts:{impersonationlevel=impersonate}!\\.\root\cimv2") ssql = "select time,source,event,categorynum,category,typenum,type,user,computername,insertion1,insertion2,data win32_ntlogevent logfile = 'system' , sourcename = 'service control manager'" set resultset = objwmiservice.execquery (ssql) each objevent in resultset ... next
is there way sort resultset
time
column?
wql indeed doesn't have ordering clause, sorting directly in query not possible. can put returned data in disconnected recordset , sort recordset:
set datalist = createobject("ador.recordset") datalist.fields.append "time", 7 datalist.fields.append "source", 200, 255 datalist.fields.append "event", 3 ... datalist.open set wmi = getobject("winmgmts:{impersonationlevel=impersonate}!//./root/cimv2") qry = "select time,source,event,categorynum,category,typenum,type,user,computername,insertion1,insertion2,data " & _ "from win32_ntlogevent " & _ "where logfile='system' , sourcename='service control manager'" each evt in wmi.execquery(qry) datalist.addnew datalist("time") = evt.time datalist("source") = evt.source datalist("event") = evt.event ... datalist.update next datalist.sort = "time" datalist.movefirst until datalist.eof wscript.echo datalist.fields.item("time") & vbtab & _ datalist.fields.item("event") datalist.movenext loop
adjust data type of fields required.
Comments
Post a Comment