'first part
On error resume next
strComputer="AHAUKC-S3004"
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colFileList = objWMIService.ExecQuery ("ASSOCIATORS OF {Win32_Directory.Name='C:\INSTALL\IBMSNMP_001'} Where " & "ResultClass = CIM_DataFile")
For Each objFile In colFileList
txt= objFile.name
tmp1 = (Right(txt,3))
if (tmp1="log") then
tmp2=txt
else
end if
Next
Const ForReading = 1
Const ForWriting = 2
Const TriStateUseDefault = -2
strFile = tmp2
wscript.echo tmp2
'second part
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile(strFile)
intSize = objFile.Size
Set objStream = objFile.OpenAsTextStream(ForReading, TriStateUseDefault)
If intSize > 1024 Then
objStream.Skip(intSize - 512)
End If
Do Until objStream.AtEndOfStream
strNextLine = objStream.ReadLine
If Trim(strNextLine) <> "" Then
strLine = strNextLine
End If
Loop
objStream.Close
wscript.echo strLine
|