Set FileList = objWMIService.ExecQuery _ ("ASSOCIATORS OF {Win32_Directory.Name='C:/Logs'} Where " _ & "ResultClass = CIM_DataFile")
For Each objFile In FileList Set objTextFile = objFSO.OpenTextFile(objFile.Name, ForReading) strText = objTextFile.ReadAll objTextFile.Close objOutputFile.WriteLine strText Next
objOutputFile.Close
实际上,我们在此处执行的全部操作是获取 C:/Logs 文件夹中所有文件的集合;这是通过以下 WMI Associators of 查询实现的:
Set FileList = objWMIService.ExecQuery _ ("ASSOCIATORS OF {Win32_Directory.Name='C:/Logs'} Where " _ & "ResultClass = CIM_DataFile")